Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 6534  / 2 Years ago, tue, december 14, 2021, 1:56:07

I'm trying to find files containing *.nef and move them to a subdirectory name NEF of the folder in which the file is found.



I've started testing with the following command, but this always copies to my current directory, which is my home folder.



find testfolder/*.nef -exec mv NEF ;


In the man find section i've read about using -execdir, but using this instead of -exec still has the same result.



So the question is: how can i dynamically assume the currently found directory and mv found files to a sub-directory folder named NEF? (which does not yet exist)



Thanks in advance!


More From » directory

 Answers
7

You were right in considering -execdir. Something simple like the below should work



find testfolder/ -name '*.nef' -execdir mkdir -p NEF ; -execdir mv {} NEF/ ; 

[#24149] Wednesday, December 15, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
imberst

Total Points: 370
Total Questions: 107
Total Answers: 123

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
imberst questions
;