sedekk Posted December 3, 2021 Posted December 3, 2021 Newbie level question: I have a found set of MP3's inside a container field. 2 things I need to do: FIRST Export field content to an existing folder on the computer C:/Playlist/ Using GetDesktopPath is useless to me, unless I could export to ../Desktop/SomeFolder/ GetFolderPath seems good, but even after watching examples, I still don't understand the syntax. Has the script step GetDirectory vanished in FM Pro 18 ? THEN Later, I will delete all MP3 files inside the folder C:/Playlist/ I remember how to do it with DOS commands but not launched from Filemaker. I suppose Send Event should be used, but I don't get how the syntax works. Watching examples did not help so far.
comment Posted December 3, 2021 Posted December 3, 2021 I don't understand your question. If you know that you want to export the files to a specific folder, then what else do you need? Why can't you simply hard-code the path to the target folder in your script and be done? 1 hour ago, sedekk said: Has the script step GetDirectory vanished in FM Pro 18 ? I believe it has been renamed to Get Folder Path in version 18. I cannot find any mention of the change in the documentation, but the descriptions are identical. 1 hour ago, sedekk said: Later, I will delete all MP3 files inside the folder C:/Playlist/ Wouldn't it be more convenient to use the temp folder then, and have Filemaker delete the files for you at the end of the session?
sedekk Posted December 4, 2021 Author Posted December 4, 2021 Thank you for your input. I was finally able to make the script go to Desktop/Playlist. That first part is now OK and I can keep the folder permanent if I wish so. Part Two: I downloaded a sample file with a script that deletes the content of a permanent folder on the desktop. However, when I replicate it, nothing happens. (no error message either) The only difference is the name of the folder on the desktop. (See attached image) Any hint ?
comment Posted December 4, 2021 Posted December 4, 2021 AFAICT, the script you show does NOT delete the contents of a folder. There are several methods to delete individual files. If you want to delete all files in a folder, I believe the simplest way to do this would be by using the Send Event script step. I am not a Windows user myself, but here are some previous posts that you might find helpful: https://fmforums.com/topic/93922-how-to-delete-import-file-after-processing-records-into-fm13/ https://fmforums.com/topic/78237-delete-file-in-windows/
sedekk Posted December 4, 2021 Author Posted December 4, 2021 Thank you for the links. One question: For other fields, I might later have to export a Found Set to let's say: c:/SomeFolder/ which is already created and not to be deleted When I create the GetFolderPath step, I have Default folder where I enter a calculation. I supposed the path "c:/SomeFolder/" should be it. Trial & error has I don't master the syntax. Then, the Export Field step: it has many options. I tried anything I could think of. When I run the script, it will always ask to choose a folder. Whatever I do, I have the message ".. could not be created on this disk." Endless causes of error to search. Maybe Default folder should remain empty. Could you give me a simple script using c:/SomeFolder/ Thank you. Quote
comment Posted December 5, 2021 Posted December 5, 2021 9 hours ago, sedekk said: Could you give me a simple script using c:/SomeFolder/ It is difficult because you didn't post your own script - so I don't know if you're exporting a found set or field contents. You speak of both interchangeably, which is quite confusing. I also don't know what you want to use as the name of the exported file. I suspect it's actually the fie name you're missing, not the folder. Try something simple like this: Set Variable [ $path; Value:"/c:/SomeFolder" ] Set Variable [ $filename; Value:"test.mp3" ] Export Field Contents [ YourTable::ContainerField; “file:$path/$filename” ] This should export the file from the container field in the current record to the SomeFolder directory located at the top level of the c drive, and give the name test.mp3 . To clarify: in the Export Field Contents step, for the 'Specify target field' option you should select the container field, and for the 'Specify output file' option you should enter exactly this: file:$path/$filename Untested, because I am not on Windows.
sedekk Posted December 6, 2021 Author Posted December 6, 2021 Thank you for the script you gave me. It works fine. I will have to modify it, since I have to copy my found set instead of a single record. Also, I must find a way to keep the original name of the copied MP3's intact. Clearly, GetFolderPath does not belong in my script.
comment Posted December 6, 2021 Posted December 6, 2021 1 hour ago, sedekk said: I must find a way to keep the original name of the copied MP3's intact. If you want to use the original file's name when exporting a container field's contents, then set the $filename variable to: GetContainerAttribute ( YourTable::ContainerField ; "filename" ) 1 hour ago, sedekk said: I will have to modify it, since I have to copy my found set instead of a single record. It's just a matter of looping over the records of the found set. You have an example of that in your 2nd post above. 1 hour ago, sedekk said: Clearly, GetFolderPath does not belong in my script. Indeed. You only need it if you want the user to select the target folder at runtime.
Recommended Posts
This topic is 1349 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now