You are here

Manual clean-up of unused audio files?

Hi Rui

AFAIK qtr is supposed to delete all unused audio files on exit but it doesn't seem to catch everything. I started a session recently that has been all MIDI until last night when I recorded some audio tracks. My session only uses 2 audio clips currently but there are 3 audio files in my session folder so qtr failed to zap one.

Is there a manual way to force qtr to do a clean-up?


rncbc's picture

indeed there is:

on the Files pane, either Audio or MIDI, the right-click/context-menu has this Cleanup option... it removes files there listed that aren't used or referenced by any clips in session.

the usual disclaimer applies: use it with care ;)


It did it occur to me at some point before I read your reply that I should've checked there. Maybe I thought that too obvious or something? Yes, the manual cleanup option seems to work fine, thanks.

Now I'm wondering what qtr does with unused audio files when you quit a session. It seems to delete some but not all unused files automatically so could you please explain how it decides what to delete and what to keep if you don't do a manual cleanup?

Cheers RNCBC!

rncbc's picture

rules of thumb, to keep in mind:~

- files created within a qtractor session, including the recorded and revised ones as through iterated midi clip editing/overdubbing, are considered persistent (ie. not eligible for auto-removal) as soon you hit the (explicit) save session command (ie. menu File/Save et al.): from that moment onwards, all newly lingering files are thereafter considered committed and permanent to the file-system, even though they're not referred by any clips in the current qtractor session.

the cleanup procedure mentioned before (Files/Cleanup) will only get the file names de-listed though, actual files will persist on the file-system.


yPhil's picture

This is what I use to remove the unused files (after, of course, running the aforementioned precious "cleanup" routine)

for wav in *.wav
do grep -q -F "$wav" SessionFile.qtr || rm -fv "$wav"

TODO: Get rid of the corresponding .peak files
V0.1 : Hard-crop the wav files, leaving only Nsecs before and after the actually used time (for archiving)

Thanks for your script xaccrocheur - I'll try that soon!

This should prob be included in the wiki until Rui makes it redundant :)

I've tried your qtr session dir cleaning script now xaccrocheur and it seems to do the trick, or at least it gets rid of most of the unused wavs.

Due to the way qtr saves and cleans-up its project files and the way this script works it is unable to remove every unused wav file. I had some wav files I had copied into my session dir before I imported them into qtr. I ended up removing these files from the session, using qtr's file clean-up option, saving the cleaned session and then running this clean-up script. qtr does not remove the records of files that have been imported from the .qtr file after you've removed them from the session and done a clean-up under the qtractor file window and so this clean-up script didn't remove any of them.

I'll still be using it regardless of this shortcomijng so thanks again for sharing it!

Thanks for explaining that Rui!

I'd not noticed that cleanup didn't actually delete the unused files, which is what I was actually wanting to do. I can understand why you'd be wary of having it do that though so I'd like to suggest that instead the clean-up option move all currently unused audio files into a sub-dir of the projects folder called something like Cleanup_audio_files and Cleanup_MIDI_files or just stick 'em all into Cleanup_files. That would make deleting the unused files much easier and no-one can cry about qtr accidentally deleting their stuff.

Would you accept this as Yet Another danboid Feature Request please?

Thanks Rui!

rncbc's picture

as said, files are only actually deleted from the file-system if you don't save the session where those are recorded/created; exception goes to exported files: they become permanent once created.

one very special case is about sessions saved in archive/zip format (*.qtz) where only in-use files are included, all others are ditched when the extraction directory gets cleaned up on session close (user's option).


yPhil's picture

Hi, here is my latest version ; Master Capela, can you confirm that it will effectively delete any leftover file?
Note: It is designed to work with both zsh and (ba)sh

function px-qtractor-takes-cleanup () {
    [[ "${2:-}" == "--delete" ]] && COMMAND="rm -fv" || COMMAND="ls"
    echo "Usage: $0 qtr_session_file [--delete)]"
    for file in *.wav* *.mid* ; do
        grep -q -F "$file" $1 || eval $COMMAND " $file"

Is this part of a separate script? or is added before compiling?


Add new comment