How can I remove blank spaces from files and folders names, but just at the beginning and at the end of the files and folders names?
Thanks.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThere are apps that do this but I am not endorsing anything. In my experience, these apps save me hours, if not days, of work as often I need to rename or clean up thousands of images being imported from a camera.
Try searching for something like: Finder, Better, Rename.
Other than that -- you may have to write an AppleScript. There may be an AppleScript already out there. Search for AppleScripts, too.
maybe some thing like this to remove space from start of files:
for name in ; do mv -v -- "$name" "${name# }"; done
maybe some thing like this to remove space from end of files:
for name in *; do mv -v -- "$name" "${name#% }"; done
uses for loop with parameter expansion http://mywiki.wooledge.org/BashGuide/Parameters#Parameter_Expansion http://mywiki.wooledge.org/BashFAQ/073
-i
or -n
option to mv
when doing any automated move/rename operation like this -- without one of those options, mv
will silently delete any files with conflicting names (and if there are bugs in the script, that could be a lot of files).
Aug 4 at 19:15