Skip to main content

All Questions

Tagged with
0 votes
3 answers
50 views

Powershell $idValue doesn't write the extracted ID, but writes "TRUE" instead -- why?

I am writing a Windows PowerShell script to split a text file based on a delimiter, and create output filenames with an incrementing number and a captured identifier string. I've checked for syntax ...
IanS's user avatar
  • 183
0 votes
1 answer
297 views

Select all lines starting with a given string and ending with " with Regex [duplicate]

Using Regex I would like to select all the contents between two " of all the lines that begin with this string: [2] 1 string data = " I tried the following code: (?<=\[2\][^=]+? 1 ...
Kenryoku's user avatar
1 vote
1 answer
401 views

Powershell rename-item using RegEx for filename irregular pattern

I have filenames in a directory that have different beginning strings of characters that I wish to strip out and leave just the alpha characters + file extension: [example] 1-09. But Not for Me.mp3 1-...
Jeff Taylor's user avatar
0 votes
4 answers
1k views

How do we search for files which contain a specific word and end in a specific file-type suffix?

How do we use Microsoft Windows PowerShell and Regular Expressions (Regex) in order to find all of the pictures (image files) on a computer such that the file name contains the word "dog". ...
Toothpick Anemone's user avatar
0 votes
1 answer
721 views

How to delete a line based on a regex string in Powershell?

I want to validate if the line above a certain line is there, then ok. if else, then delete that line and remove the empty space ? Can this be done in powershell? please help If before all lines ...
coder234's user avatar
1 vote
1 answer
356 views

Extract variable names from .txt file with RegEx

I want to extract a variable name (e.g. $00incomplete_frame) from a text file and place the names in a variable for use in PowerShell. The source variable names do not contain spaces. A source file ...
LouF's user avatar
  • 71
1 vote
1 answer
313 views

Select two 1 hour (HH:MM) string values with regular expressions

I have the string or text data: [string]$hours = @" 10/10/2022 08:11 14:34 06:23 00:00 11/10/2022 08:05 14:28 06:23 00:00 12/10/2022 - - 00:00 00:00 Día Festivo 13/10/2022 ...
zeros's user avatar
  • 271
0 votes
1 answer
383 views

select two random words from a text with regular expression

I have the following code: [string]$namesList = @" casa fuentes, jose lopez casimiro juan gazquez san antonio anto vazques "@ How do I select the first two words? output expected: casa ...
zeros's user avatar
  • 271
2 votes
1 answer
5k views

How can I use Powershell to rename all files where the name has the format "digits [space] name with spaces" to "digits [hyphen] name with spaces"?

I have a lot of files with names of the format "digits [space] name with spaces" or "(digits) [space] name with spaces" e.g.: 23 Filename 23 with spaces.txt (47) Filename 47 with ...
ChrisF's user avatar
  • 41.3k
0 votes
1 answer
2k views

How to implement regex on a powershell find and replace to quickly change file names in windows 10?

Hi I have a set of files in a folder (windows 10) that are named something like this: asfdjlaksjfdi09908jfakl.part1.rar aabdjkhihsdjkf.part2.rar sdjklufia9798uiownlnsadkfasdFASDFrwe34342.part3.rar ... ...
easy ijoijo's user avatar
0 votes
2 answers
1k views

Powershell: How do I shift a date (format: yyyymmdd) from any position in the file name to end of the file name?

Currently im using dir | Rename-Item -NewName {$_.name -replace "",""} to rename files in a directory. The file names vary and need to be unified. Examples for file names: ...
schwadinho's user avatar
0 votes
0 answers
239 views

Trouble chaining together foreach and if/then/else in Powershell

I have a text document containing 80 filenames of a similar format. The last 4 digits of each filename indicates its subdirectory location, for example: wheat_bread_12345678.doc will always be located ...
Ace's user avatar
  • 1
0 votes
1 answer
366 views

Regex: Can be find the html links (string) on several html files, which are repeated? (find duplicates)

I have a lots of meta description, as this one, in my html pages. <meta name="description" content="My name is prince."/> <meta name="description" content="...
Just Me's user avatar
  • 866
1 vote
1 answer
144 views

Regex: Put some tags at the beginning of the line, but only those that are framed in a comment html

I wanna put some tags at the beginning of the line, but only those that are framed in a comment html. For example: <!-- ARTICOL START --> <p class="text_obisnuit">I want go home&...
Just Me's user avatar
  • 866
0 votes
1 answer
2k views

PowerShell script to check the name format of all folders in a directory and create subfolders in each one

I have a Main folder which contains many folders with the name format: capital letter and four numbers (A4431). The script in PowerShell I am trying to write needs to go through all the folders in my ...
imphetuss's user avatar

15 30 50 per page