powershell - Batch rename files with regex -


i have number of files following format:

name_name<number><number>[tif<11 numbers>].jpg

e.g. john_sam01 [tif 15355474840].jpg

and remove [tif 15355474840] of these files includes leading space before '[tif...' , different combination of 11 numbers each time.

so previous example become: josh_sam01.jpg


in short, using powershell (or cmd.exe) regex turn filename:

josh_sam01 [tif 15355474840].jpg

into this:

josh_sam01.jpg

with variables being: 'john' 'sam' 2 numbers , numbers after tif.

something like, added newlines clarity:

dir ‹parameters select set of files› |    % {      $newname = $_.name -replace '\s\[tif \d+\]',''      rename-item -newname $newname -literalpath $_.fullname    } 

almost adding -whatif rename until sure had file selection , rename correct.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -