4

We have created a lot folders and files that contains the "<" character.

Is it possible to mass-remove these characters?

4

I use Name Mangler 3 for file and folder renaming. There are free options out there, but Name Mangler offers a ton of features that make it well worth the $19.00 to me.

Here is Name Mangler on MacUpdate which includes links to many similar programs.

  1. Once you have Name Mangler installed, launch it
  2. Drag all of the folder you want to rename into the panel where it says "Drag Files and Folders Here"
  3. On the right choose "Find and Replace"
  4. Enter "<"
  5. Under "Replace with" enter the character you want to replace "<" with or leave blank to remove it
  6. Click "Rename x of x items"

Once of the many things that makes using a tool like Name Mangler valuable is that you can undo your changes, view a history of your changes, and create a "droplet" that make running the name change on other files really convenient. All of that plus being able to use Regex to build very complicated renames.

There is also a great Name Mangler Google Group where you can get your questions answered and some very advanced features and methods get discussed. They have been a big help to me.

  • Gonna try this, hold on! – Vinozio Sep 28 '14 at 12:55
  • I found this application very useful to change files and folders! Thank you! – Vinozio Sep 28 '14 at 14:25
13

You can do this quite simply and quickly in Terminal:

cd /path/to/start/renaming

find . -name '*\<*' | while read f; do echo mv "$f" "${f//\</}"; done

The command above is a "dry-run" of the command below:

find . -name '*\<*' | while read f; do mv "$f" "${f//\</}"; done

This will remove any < characters recursively on files and folders starting from the path you cd into initially.

Result:

mv ./<folder<test<   ./foldertest
mv ./<test3.txt      ./test3.txt
mv ./test2<.txt      ./test2.txt
mv ./test<test.txt   ./testtest.txt
  • Is it possible that this command takes a while? I'm doing the dry-run and there is no output after 5 minutes? – Vinozio Sep 28 '14 at 15:22
  • 1
    @Vinozio, How many directories are you scanning? It should be almost instantaneous if not many. If you're starting at / for example it could take a while. Try using the command in a directory where you know there's a file/folder with the < in the name and see what it does. – l'L'l Sep 28 '14 at 15:35
  • It's on a NAS, with 250 GB of Data. – Vinozio Sep 28 '14 at 15:40
  • 1
    @PubliDesign : mv doesn't delete files, it moves them; with any command in terminal please know what you're doing and the risks of such things beforehand. The first command shown is a "dry-run", meaning you should've executed that first to be certain what it does, as it doesn't touch any files. If you overwrote your files somehow that's nobody's fault but your own... – l'L'l Apr 11 '17 at 15:02
  • 1
    @davewoodhall: Do you actually believe "This deleted my files" is useful? – you deleted them, take responsibility perhaps! This question was answered almost three years ago, has nearly 10,000 views and nobody else seems to complain of anything similar. Unfortunately I'd say you messed up somewhere along way, sorry... – l'L'l Apr 11 '17 at 19:55
1

It can be done with shellscript or Automator, but possibly NameChanger might be the simplest option, it's donationware - NameChanger-MRRSoftware

1

You can easily do this with a shell script (free), e.g.:

!#/bin/ksh
for filedirname in `ls -1 *\<*` # Note ls -1(one) not the alphabet L
do
    NEW_NAME=$(echo "$filedirname" | sed 's/\<//g')
    mv "$filedirname" "$NEW_NAME"
    echo "Changed name from $filedirname to: $NEW_NAME"
done
  • the -1 isn't really necessary (ls creates single column output anyway if output is not sent to a screen), also for f in *\<*; do should work as well. – nohillside Sep 28 '14 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .