f2 icon indicating copy to clipboard operation
f2 copied to clipboard

Moving files to another directory outside starting path

Open joeldebruijn opened this issue 1 year ago • 5 comments

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:

  1. 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.
  2. 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?

joeldebruijn avatar Nov 04 '23 11:11 joeldebruijn

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.

ayoisaiah avatar Nov 05 '23 10:11 ayoisaiah

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 avatar Nov 05 '23 10:11 joeldebruijn

@joeldebruijn Yes essentially a flag to specify a different root directory will do trick, but will explore other options too 🙂

ayoisaiah avatar Nov 05 '23 14:11 ayoisaiah

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

joeldebruijn avatar Feb 16 '24 12:02 joeldebruijn

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

ayoisaiah avatar Feb 16 '24 12:02 ayoisaiah

@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.

ayoisaiah avatar May 10 '24 17:05 ayoisaiah

Will try and test! Thnx!

joeldebruijn avatar May 10 '24 17:05 joeldebruijn