[OFF] utility for files
David Hood
david.hood at stonebow.otago.ac.nz
Sat Feb 15 21:48:39 CST 2003
On Saturday, February 15, 2003, at 08:32 PM, Ruslan Zasukhin wrote:
> Hi Guys,
>
> Anybody know if exists such tool for MAcOS X which can do next task.
Applescript.
As an example for changing names in all the files in a folder
> A) add prefix to many files.
set newPrefix to "old_"
tell application "Finder"
activate
set theFolderIWant to choose folder
set ListofDocuments to every document file of theFolderIWant
repeat with aDocument in (ListofDocuments as list)
set oldName to name of aDocument
set name of aDocument to newPrefix & oldName
end repeat
end tell
> B) change prefix of files
Using OSX with the command line:
set oldPrefix to "old"
set newPrefix to "FBL"
tell application "Finder"
activate
set theFolderIWant to choose folder
set ListofDocuments to every document file of theFolderIWant
repeat with aDocument in (ListofDocuments as list)
set oldName to name of aDocument
set newname to (do shell script " echo " & oldName & "| sed
s/" & oldPrefix & "/" & newPrefix & "/")
set name of aDocument to newname
end repeat
end tell
Since the last example calls the unix shell it may need a bit of work on
unusual characters that need escaping (but it worked fine on a test
folder I tried it on. This version would also go wrong if the searched
for string appears elsewhere in the filename.
Regards,
David Hood
More information about the Valentina
mailing list