• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Move files to the right folder.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move files to the right folder.


  • Subject: Re: Move files to the right folder.
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 16 Oct 2006 17:09:19 +0200


Le 16 oct. 2006 à 13:53, Jan Bultereys a écrit :

Hi, I am looking for a script which moves file to the right folder based on
the name of the files.

Folders:

 00000-00099_Vendor_Code
 00100-00199_Vendor_Code
 00200-00299_Vendor_Code
 00300-00399_Vendor_Code
 00400-00499_Vendor_Code
 00500-00599_Vendor_Code
.....
 12000-12099_Vendor_Code

Name of the files:
BE_00097_M3200W
BE_00158_M1370

So based on the number between BE_ and _M3200W the file should be moved to
the right folder, in this case to the folder (for the 1st example):
00000-00099_Vendor_Code


Hello

Maybe this one may do the trick

--[SCRIPT]

(*
define here the sourceFolder

set sourceFolder to "xxxxxxxx:yyy:zzz:"

*)

set mainFolder to (path to documents folder) as text
set destName to "Vendors_srodneV"
tell application "Finder"
if not (exists folder (mainFolder & destName)) then make new folder at folder mainFolder with properties {name:destName}
end tell
set destFolder to mainFolder & destName

set theFiles to "BE_00097_M3200W
BE_00158_M1370"
if theFiles contains return then
set delim to return
else
set delim to ASCII character 10
end if
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
set FilesNames to text items of theFiles
set AppleScript's text item delimiters to oldDelim

repeat with tt in FilesNames
set tt to tt as text


set ff to ((text 4 thru 6 of tt) as text) & "000_" & ((text 4 thru 7 of tt) as text) & "_Vendor_Code"
(*
-- Commented code because sourceFolder is not defined
tell application "Finder"
if not (exists folder destFolder & ff) then make new folder at folder destFolder with properties {name:ff}
move file (sourceFolder & tt) to folder destFolder & ff
end tell
*)
log tt & "*,*" & ff
end repeat

--[/SCRIPT]

Yvan KOENIG
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Move files to the right folder.
      • From: kai <email@hidden>
References: 
 >Move files to the right folder. (From: Jan Bultereys <email@hidden>)

  • Prev by Date: Re: How to refresh a subscribed calendar?
  • Next by Date: Re: TextEdit find/replace script
  • Previous by thread: Re: Move files to the right folder.
  • Next by thread: Re: Move files to the right folder.
  • Index(es):
    • Date
    • Thread