Delete watchfolder directories/subdirectories after Processing all Files

Questions and answers on how to get the most out of FFAStrans
Post Reply
Borky
Posts: 3
Joined: Tue Aug 16, 2022 9:15 am

Delete watchfolder directories/subdirectories after Processing all Files

Post by Borky »

Hi there!
I'm new to FFastrans and have gotten stuck on a problem that probably isn't all too complicated to solve. I would like to delete all directories/subdirectories that are inside my watchfolder once everything is processed. The original files, in my case mp3's, are deleted once they land in my output folder, so all that's left in my watchfolder are empty directories. I have a working command processor for deleting the directories but have yet to figure out how to correctly trigger it. My first thought was using a conditional processor to do something in the likes of:
if exists("watchfolder/*") == 0 " then trigger delete directories else run workflow. Thanks in Advance.---
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by admin »

HI Borky, thank you for using FFAStrans and welcome to the forum! :-)

You can try and add a command executor node at the end of your workflow with this command:

%comspec% /C "robocopy "%s_original_path%" "%s_original_path%" /S /move"

This is a nice little trick to remove all empty folders and subfolders from the %s_original_path%, being the watch folder.
Hope this helps.

-steinar
Borky
Posts: 3
Joined: Tue Aug 16, 2022 9:15 am

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by Borky »

Hi Steinar,
thanks for the fast reply and the solution. The command does work to some extent but will only delete the directories containing the processed files. A quick example, if I have a directory hierarchy "artist -> album", only the album directories will be deleted since they contain the to be processed tracks.

Thanks in advance
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by ThomasM »

Hey Borky,

As I understand the Robocopy-Command it only deletes EMPTY folders by MOVING the original Path OVER the destination path (which are the same). So a soulution could be to execute the command twice - so use two nodes to delete both folders...

p.s.: be aware, that also other empty folders will be deleted.

Another workaround could be to check for remaining files in the folder by a conditional-node (Function EXIST "original Path/*.WAV" = 0).
-> TRUE: then RD/SQ [Add the correct path, using OriginalDrive/OriginalPath~n...)/ArtistFolder (Remove Directory) in a new node. TRY THIS IN A SAVE ENVIRONMENT pleas, as I am not in my studio to test this on my own...

cheers,
tom
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by ThomasM »

Hey Borky,

Sorry for confusing - but... I tested a bit. Especially when you use multiple Job Slots (Options -> Configuration -> Host) the workflow may run into trouble as it processes the original folder multiple times. I send a Workflow along which worked for me. It has a double RD-Command-Executor with a Delay-Node and the delayed RD-Node has no exit-code function.

Please test in a sandbox...

regards
tom
Attachments
Tom_ProcessFLACdelAlbumFolder.json
(8.95 KiB) Downloaded 204 times
Borky
Posts: 3
Joined: Tue Aug 16, 2022 9:15 am

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by Borky »

Hey Thomas,

thank you for the suggestions and the workflow, will try it out today. We've got a somewhat working workflow so far but are still tweaking around with the conditional node, which seems to run into problems with hidden files such as ".db's".

Thanks,
Borky
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: Delete watchfolder directories/subdirectories after Processing all Files

Post by ThomasM »

Hey Borky,

in the Conditional-Node try to find only your Audio-Files like

Code: Select all

$exists("%s_original_path%\*.FLAC")
or

Code: Select all

$exists("%s_original_path%\*.wav")
in the following Executor-Node the command

Code: Select all

%comspec% /C "RD /S /Q"D:\TEST\%s_recursed_path%""
will delete the Folder regardless, what is left in it.

hope this helps.

regards
tom
Post Reply