{this is for Windows}
For a program I am writing need to be able to seporate files in a folder into 2 different folders
In my program I have user select a folder and it put files into fList.
now I want to move certain files (based on user defined extensions) into one folder (call it Folder A) and others (based on second list of extensions) into another and ignor all other files.
The folders are already created.
There are fields for the user to put the file extentions into.
fld Graphics and fld Documents. The defaults for Graphics is: .txt, .doc
and the defaults for Documents is: .jpg, .gif, .png but the user can add more (seporating with comma).
I have tried several recursive methods to go through the files and move them to the the folders but nothing has worked so far. My main problem is I cant figure out how to pull the file path out of fList based on the extension.
much thanks in advance.
moving files to different folders based on extension
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
you most likely want to look at the itemdelimiter. Adjust the following for your needs
Code: Select all
put "c:/documents/" into thePath
repeat for each line theLine in fList
set the itemdelimiter to "."
if item -1 of theLine is among the lines of field "documents" then
set the itemdelimiter to "/"
rename file theLine to thePath & "/" & item -1 of theLine
end if
end repeat
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Thank you so very much.BvG wrote:you most likely want to look at the itemdelimiter. Adjust the following for your needsCode: Select all
put "c:/documents/" into thePath repeat for each line theLine in fList set the itemdelimiter to "." if item -1 of theLine is among the lines of field "documents" then set the itemdelimiter to "/" rename file theLine to thePath & "/" & item -1 of theLine end if end repeat
not sure what most of that code does, but
Code: Select all
repeat for each line theLine in fList
set the itemdelimiter to "."
if item -1 of theLine is among the lines of field "documents" then
end if
end repeat