Page 1 of 1
Does a file exist
Posted: Sat Jan 21, 2017 8:14 pm
by maxs
I've been exporting files to my document folder, like " export image "seats" to file "seats.png" as PNG"
How can I tell if a file exists outside the app? The "exists" function work only with files inside LC.
Also, Is there a way to delete a file in my documents folder?
Max
Re: Does a file exist
Posted: Sat Jan 21, 2017 8:44 pm
by jmburnod
Hi Max,
Yes both we can
How can I tell if a file exists outside the app? The "exists" function work only with files inside LC.
Code: Select all
Answer (there is a file MyFilePath)
Also, Is there a way to delete a file in my documents folder?
Code: Select all
put specialfolderpath("documents") & "/" & MyFileName into MyFilePath
delete file MyFilePath
Best regards
Jean-Marc
Re: Does a file exist
Posted: Sat Jan 21, 2017 11:41 pm
by maxs
Thank you,
So simple, and so quick. This really helps.
Re: Does a file exist
Posted: Wed May 24, 2017 7:48 pm
by gagsoft
Hi
I am looking for something similar. I want to delete all files in a specific folder.
My code: This does not work.
Code: Select all
on mouseUp
put specialFolderPath("documents") & "/" & "psendwip/" & "*.*" into tFilesToWipe
delete file tFilesToWipe
end mouseUp
Any help would be appreciated
Thanks
Peter G
Re: Does a file exist
Posted: Wed May 24, 2017 9:40 pm
by jmburnod
Hi Peter,
To delete all files of a folder you have to get the list of files. You can do it with "the files" after you have defined target folder as default folder
Once you get this list you can use a loop to delete all files.
Something like that:
Code: Select all
on mouseUp
put specialFolderPath("documents") & "/" & "psendwip" into tFolder --psendwip = the name of folder target
set the folder to tFolder--define default folder
put the files into tAllFiles-- get list files
repeat for each line tOneFile in tAllFiles --a loop to delete all files
put tFolder & "/" & tOneFile into tPathFile
delete file tPathFile
end repeat
end mouseUp
Best regards
Jean-Marc
Re: Does a file exist
Posted: Thu May 25, 2017 9:02 am
by gagsoft
Hi Jean-Marc
Many thanks
Works like a charm.
Really appreciate this.
Best
Peter G