0

I need to remove "asc_" and "cs" across hundreds of file names which the middle portion is a unique name. I was able to only remove "asc" based on below rename command.

rename "asc_wildcard*.wildcard*" "////wildcard*.wildcard*"

asc_1234567_cs.jpg

asc_1234568_cs.jpg

asc_1234569_cs.jpg

Anyone can assist?

Zman
  • 1

1 Answers1

0

To remove both "asc_" and "cs" from the file names, you can use the following rename command:

rename 's/asc_//' *
rename 's/cs//' *

This will remove "asc_" from all files and then remove "cs" from all files.

If you only want to apply the changes to certain file types, you can specify the file type using a wildcard. For example, to only rename JPEG files, you could use the following command:

rename 's/asc_//' *.jpg
rename 's/cs//' *.jpg

Note that the rename command may not be available on all systems. If you are using a system that does not have rename, you can use the find and mv commands to achieve the same result.

find . -name "asc_*" -exec mv {} `echo {} | sed 's/asc_//'` \;
find . -name "*cs*" -exec mv {} `echo {} | sed 's/cs//'` \;

This will find all files with names starting with "asc_" and move them to a new location with the "asc_" portion removed, and then find all files with "cs" in the name and move them to a new location with "cs" removed.