Saturday, July 4, 2020

#1 2002-03-19 08:09:54 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Mac OSX folder move


I am trying to move a named folder into a newly created folder with a given name; I can create the new named folder, but can't move the existing one into it. Can anyone help; I am including the while script for you to see what I might be doing wrong (or right).




set xf to "folderX" set the_folder to alias "Drive1: Backup Folder:"
set destination_folder to the_folder
copy ((offset of (the month of (current date)) in ¬
"jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4 ¬
as integer to mo if mo < 10 then copy "0" & mo as string to mo copy day of (current date) to da
if (day of (current date) < 10) then copy "0" & da as string to da
copy mo & "/" & da & "/" & (year of (current date) as string) to shortDate

tell application "Finder"
get shortDate as string
make new folder at destination_folder with properties {name:shortDate}
delay 2
list folder of alias "Drive1: Backup Folder:"
if folder xf exists then
select folder xf of destination_folder
move selection to destination_folder
end if
end try
end tell

Thanks again for your help.

One mans trash is another mans treasure

Filed under: Finder



#2 2002-12-07 02:12:50 pm

Registered: 2002-12-07
Posts: 43

Re: Mac OSX folder move

The "make new folder" command returns the path to the newly created folder. So


set new_folder to make new folder at destination_folder with properties {name:shortDate}

then attempt the move, which need be nothing more than


move new_folder to destination_folder

You don't say where the code is failing. Is the try catching some error? Is the boolean test of the "if" ever true (and it's not necessary, since it's within a try..end try block).

I don't understand what the contents of the code between the try...end try is supposed to do. One command lists the contents of folder, but the result isn't stored or tested against anything, another command selects a folder, but no selection is necessary to execute a move command.[/applescript]



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)