Thanks to all of you.
Here is a version which behaves well.
--set sourcefolder to (path to desktop as text) & "formoosmahna:" as alias --set keyName to "staff_01"
set sourceFolder to choose folder set keyName to text returned of (display dialog "Type a folder name" default answer "Staff_01")
tell application "System Events" set theSubFolders to folders of sourceFolder repeat with aSubfolder in theSubFolders set itsFiles to (files of aSubfolder whose visible is true) if itsFiles is not {} then set movableFiles to {} repeat with aFile in itsFiles if name of aFile contains keyName then set end of movableFiles to contents of aFile end repeat if movableFiles is not {} then set dest to (path of aSubfolder as text) & keyName & ":" if not (exists folder dest) then make new folder at end of aSubfolder with properties {name:keyName} end if set posixDest to quoted form of (get POSIX path of disk item dest) repeat with aFile in movableFiles set qSource to quoted form of (get POSIX path of aFile) do shell script "mv " & qSource & space & posixDest end repeat
end if end if end repeat end tell # System Events
The get was needed and it’s required to convert the string dest into the disk item dest.
Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) jeudi 10 décembre 2015 11:15:21
|