Moving a group of files in to a directory

galileo1

New Member
Joined
Oct 3, 2019
Messages
2
Reaction score
1
Credits
0
Good afternoon.

I've been trying to find a way to move some files (example below) to a specific directory called Archives. So far, I've been moving them one by one but, as you can probably guess, it's getting tiresome. Any way to do this as a group (as in all files for the month of August)? I'm just not sure of the command I'd use to grab all of these files in one chunk.

takoma_August-30-2019_14:30:01
takoma_August-29-2019_14:30:02
takoma_August-28-2019_14:30:02
takoma_August-27-2019_14:30:02
etc
etc
etc

Any help will be tremendously appreciated.

Rob
 


Why can't you use a Package Manager?
 
I could...I just wanted to find a quick command that would do it for me.
 
cd to inside directory where files are, if they are in sub you might try " -r"

try something like: ls *August* | cpio -o > /home/username/Desktop/ archive/files.cpio

where a dir called archive on your Linux Desktop is where backup of files will go and archive of files will be files.cpio
 
I've been trying to find a way to move some files
So, that sounds like the "move" command, mv, is all you need. I'll assume your Archives folder is in your home folder. First, open a terminal in the folder where your files are, then:
Code:
mv tak* ~/Archives


But this may be too simple. If you have binaries, or libraries, or config files, or anything else that starts with "tak"... they would be moved too. If so, then you just need to add a little more to the string to make sure it only gets what you want. This should get all of your August files:
Code:
mv takoma_Aug* ~/Archives


If your Archives folder is not in your home folder, you'll need to be more specific with the path.
Code:
mv takoma_Aug* /path/to/Archives


Your example does not look like there is any risk of duplicating file names, but if there is a chance... you should use an option like mv -i so that the move command will prompt you before overwriting data. See man mv for more details about using the move command.

Cheers
 
[dragondax@devbox tmp]$ ls -l
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-29-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-27-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-26-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:03 takoma_August-28-2019_14:30:02
[dragondax@devbox tmp]$ find . -name "*August*" -exec mv {} new/ \;
[dragondax@devbox tmp]$ ls -l new/
total 0
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-26-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-27-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:03 takoma_August-28-2019_14:30:02
-rw-rw-r--. 1 dragondax dragondax 0 Dec 20 01:04 takoma_August-29-2019_14:30:02
[dragondax@devbox tmp]$
 
Good afternoon.

I've been trying to find a way to move some files (example below) to a specific directory called Archives. So far, I've been moving them one by one but, as you can probably guess, it's getting tiresome. Any way to do this as a group (as in all files for the month of August)? I'm just not sure of the command I'd use to grab all of these files in one chunk.

takoma_August-30-2019_14:30:01
takoma_August-29-2019_14:30:02
takoma_August-28-2019_14:30:02
takoma_August-27-2019_14:30:02
etc
etc
etc

Any help will be tremendously appreciated.

Rob



Try this:

mv {etc*,takoma*} /path/to/archives_dir/
 

Members online


Top