moving files


I have a problem in that I need to move a large amount of files to a Linkstation NAS. However a smallish number of these files have filenames >32 chars in length, which the Linkstation won’t accept.

Therefore my question is can an applescript be written to allow me to move all files with a filename >32 chars to a new location on an internal HD first, thus allowing me to copy the remaining files to my Linkstation without getting multiple errors about filename lengths.

I would really appreciate any assistance anyone can offer.

I have no previous knowledge of applescript, and am using OS 10.4.3.

many thanks

Model: G5
Browser: Firefox 1.5
Operating System: Mac OS X (10.4)


You should be able to use the shell, as I believe it does not care about filename length. Here is a scriplet I put together and tested on a 52+ character length filename, and it worked mahvelously:

set a to choose file
tell application "Finder" to set aaa to a's name --To use the [mv] command in the shell, you need a full path, including filename.  The variable [aaa] is the filename, regardless of length.
set aa to quoted form of (POSIX path of a) --Makes the chosen file readable to the shell.
set b to path to documents folder as Unicode text --Simply an example of a folder to place all the files.
set c to quoted form of (POSIX path of (b & aaa)) --Builds the new path [b & aaa] and makes the string readable to the shell
do shell script "mv " & aa & " " & c --Move it, baby!

Some things to remember about this command are that if the two paths are not similar, meaning that if [aa] or [c] do not both refer to files or folders, you could quite probably lose your data. If one is a file, and the other is a folder, it will mess you up bad. Another thing to remember is that this MOVES the file, without leaving a copy in the original location, so be sure you want to do that before you move forward. You will also be interested to know that you are certainly allowed to change the name of the file as part of the move. For instance, instead of just using [aaa] to make a new file reference, you could install another string, and move and rename all at once.

If any of this is confusing, please re-post and I, or another scripter, would be overjoyed to help you do this. It sounds like a perfect job for a nice little AppleScript calling the shell.

Good Luck