how can I move files with specific names from one folder to another
Solution 1
To glob for the different names, you can use a for
loop like so
for f in /Users/Marine/Descktop/folderGN/{*[Pp]rotein*,*MSMS*,*PSms*}; do echo mv -v -- "$f" /Users/Marine/Descktop/myfolder ; done
Remove the echo
after testing to actually move the files.
I have copied your paths exactly (including the possible typo in Descktop
?), but you could instead do this with relative paths:
cd /Users/Marine/Descktop/folderGN
for f in *[Pp]rotein* *MSMS* *PSms* ; do echo mv -v -- "$f" ../myfolder ; done
(remove echo
after testing as before)
Solution 2
This is in fact very simple. If you want files with a certain letters/numbers in their name, and anywhere in the name, to be moved to some directory, just:
move *some_name* directory
Related videos on Youtube
Learner Algorithm
Updated on September 18, 2022Comments
-
Learner Algorithm over 1 year
I have read this Copying multiple specific files from one folder to another which could not help me.
I have thousands of files in
/Users/Marine/Desktop/folderGN
, some of which I want to keep and some of which I want to move.There are several files with different names and I want to move only those that have a name containing
Protein
orMSMS
orPSms
.I want to move them from
/Users/Marine/Desktop/folderGN
to
/Users/Marine/Descktop/myfolder
-
Learner Algorithm over 7 yearsthank you so much. I cannot like it too but it solved my problem. I have one more question which I will ask soon
-
Zanna over 7 years@LearnerAlgorithm you're welcome :D
-
Learner Algorithm over 7 yearsI asked another question, I would appreciate if you could help me there too askubuntu.com/questions/857999/…