I have a folder full of files and they all look like this:
frame_number_delay-number.gif
I would like to delete the frame_ and the _delay part.
Help please!
I have a folder full of files and they all look like this:
frame_number_delay-number.gif
I would like to delete the frame_ and the _delay part.
Help please!
You can use PowerShell for that. Open it and navigate to your folder that contains the files you want to rename with cd. Then run the next command:
cd C:\Path\to\your\folder
Get-ChildItem -Filter *.gif -File | Foreach-Object { Rename-Item -Path $_.FullName -NewName $_.Name.replace("frame_","").replace("_delay","") -WhatIf }
-WhatIf means this is a dry run. Remove it once you're happy with the shown result to actually rename the files.
Megamorf's answer is correct, but it can be improved, here is my two cents.
The commands can be shortened to an one-liner:
Get-ChildItem -Path "C:\Path\to\folder" -Filter "*.gif" -File -Recurse | % { Rename-Item -Path $_.FullName -NewName $($_.Name -replace "frame_|_delay") -WhatIf }
In the command "C:\path\to\folder" is a placeholder for the actual path, replace the path with the actual path when you run the command;
The -Recurse switch specifies the command to process subdirectories as well;
% when used with a scriptblock (any commands between { and }) is an alias to ForEach-Object, if not used followed by a scriptblock then it means the modulus operator (i.e. 21 % 6 will return 3), it is customary to use % indicate ForEach-Object;
The -Replace operator uses regex match, and you don't need to provide the replacement, so you can replace two strings in one step, saves a lot of characters.