I'll use the single quote to protect the spaces in the file name. The -v Q=''' is creating an awk variable with a single quote in it. I did not protect the file name spaces from the /bin/sh shell which the system() function passed the mv command to.įind /Shared\ Items/test -name '* ' | awk -v Q=''' ' I just realized there is 'Bug' in my code :-( My backup program tells me which files they are, but there are over 3000 on one server alone - I have other things I need to do over the next 2 years, lol. So please help - I can't face manually searching every single last file and folder and renaming them to see if there's a terminal space. I would say I'm an applescript novice, but I'm not even that - I'm less than novice. Basically I need to figure out some method of searching all files and folders (and subfolders etc) within a certain directory, finding those that contain a space as the final character and removing that space, without removing all the spaces further back in the name. We've started using a backup program that kicks up errors and file/folder duplicates every time it finds a file or folder with a space at the end of the file or folder name. I'm a network admin with three file servers, all hosting staff shared areas that date back to 2003 or so, sometimes even further.