f2
f2 copied to clipboard
Moving files to another directory outside starting path
Besides renaming files I'm experimenting with using F2 to move files to other folders (and migrate from Robobasket for Windows in the process).
The use case is a folder with a Camera roll and storing them somewhere else in ' daily folders' . The files are like this YYYYMMDD_hhmm,jpg
Example:
- Source is "20231007_065837.mp4"
- Target is a directory with a path in my home folder.
I tried this:
- f2 -f '(\d{8})_(\d{6}).(jpg|mp4)' -r "/$home/S/Joel/Media/Fotos/$1/{f}{ext}" assuming I could use $home as a variable.
- f2 -f '(\d{8})_(\d{6}).(jpg|mp4)' -r "/home/S/Joel/Media/Fotos/$1/{f}{ext}" assuming I could use /home as an absolute path.
Both times it creates a directorystructure /home/S/Joel/Media/Fotos/.../ WITHIN my cameraroll folder.
Is moving outside the current path possible or am I missing something?
Hi @joeldebruijn,
It's currently not possible but, this sounds like something that should be supported for sure and it should be straightforward enough to implement.
Thanks! For now I just sort within the starting path and move the resulting directories by hand once a week or so.
Maybe it needs some kind of flag to choose between relative and absolute paths?
@joeldebruijn Yes essentially a flag to specify a different root directory will do trick, but will explore other options too 🙂
I just read https://github.com/ayoisaiah/f2/wiki/F2-tutorial#integration-with-other-programs and ' piping' and make combinations with other programs. Could something like this work? Replace example is random. To move every matched file with its new filename in a new place?
f2 -f '{f}.{ext}' -r '{%03d}{ext}' | mv {%03d}{ext} $HOME/Test
What I could do is provide a flag that can help you execute a command on each renamed file. For example:
f2 -f '{f}.{ext}' -r '{%03d}{ext}' --cmd mv {} $HOME/Test
Where {}
is the file path that was renamed.
I will also add the ability to use F2's output as an input to other programs. For now, you can only use the output of other programs as input to F2
@joeldebruijn You can do something like this now (see latest nightly release):
f2 -f 'master' -r 'main' -x --non-interactive | xargs -I {} mv {} dist/
The --non-interactive
flag instructs F2 to print the renamed paths so that it can be used as input for a different program.
Will try and test! Thnx!