Questions tagged [mv]

mv is a Unix command that moves a file to a target location.

627 questions
219
votes
12 answers

How do you move all files (including hidden) from one directory to another?

How do I move all files in a directory (including the hidden ones) to another directory? For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both files to a directory named "Bar"? The following does…
Cory Klein
  • 18,391
  • 26
  • 81
  • 93
186
votes
14 answers

How can I move files and view the progress (e.g. with a progress bar)?

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.
letronje
  • 2,045
  • 2
  • 14
  • 7
124
votes
11 answers

how to rename multiple files by replacing string in file name? this string contains a "#"

https://serverfault.com/questions/70939/how-to-replace-a-text-string-in-multiple-files-in-linux https://serverfault.com/questions/228733/how-to-rename-multiple-files-by-replacing-word-in-file-name https://serverfault.com/questions/212153/replace-stri…
Leon Francis Shelhamer
124
votes
9 answers

Solving "mv: Argument list too long"?

I have a folder with more than a million files that needs sorting, but I can't really do anything because mv outputs this message all the time -bash: /bin/mv: Argument list too long I'm using this command to move extension-less files: mv --…
Dominique
  • 5,155
  • 8
  • 26
  • 29
113
votes
6 answers

How to integrate mv command after find command?

I am searching for files which name which contain AAA within their path using following command: find path_A -name "*AAA*" Given the output showed by the above command, I want to move those files into another path, say path_B. Instead of moving…
huahsin68
  • 1,847
  • 8
  • 22
  • 25
88
votes
12 answers

Is there a way to make "mv" fail silently?

A command like mv foo* ~/bar/ produces this message in stderr if there are no files matching foo*. mv: cannot stat `foo*': No such file or directory However, in the script I'm working on that case would be completely fine, and I'd like to omit…
Jonik
  • 1,460
  • 3
  • 13
  • 17
79
votes
8 answers

mv: Move file only if destination does not exist

Can I use mv file1 file2 in a way that it only moves file1 to file2 if file2 doesn't exist? I've tried yes n | mv -i file1 file2 (this lets mv ask if file2 should be overridden and automatically answer no) but besides abusing -i it also doesn't…
74
votes
5 answers

Adding unzipped files to a zipped folder

I'm trying to add unzipped files to an existing already zipped folder say new folder.zip. Is it possible to use zip -r new folder.zip after adding some unzipped files to them? Will this command compress the folder? Is there any alternative to do…
boo na
  • 741
  • 1
  • 5
  • 3
67
votes
3 answers

Why doesn't mv utility need -R (recursive) option but cp does?

I always get messed up when need to use cp or mv: "do I need -R option when working with dir?" In GNU coreutils cp does need -R and mv doesn't. I just can not find any reason why cp needs -R option for copying dirs and mv doesn't. I think that…
wobmene
  • 963
  • 1
  • 7
  • 9
65
votes
5 answers

After accidentally renaming /usr, how do I rename it back?

I accidentally renamed the directory /usr into /usr_bak. I want to change it back, so I append the path /usr_bak/bin to $PATH to allow the system to find the command sudo. But now sudo mv /usr_bak /usr gives me the error: sudo: error while loading…
Yves
  • 3,161
  • 7
  • 26
  • 54
65
votes
2 answers

How to move a file without preserving permissions

The problem is I want to be able to see errors when moving a file, but not see errors with permissions problem. In other words - I care if the file is not fully transmitted, but don't want to see errors like this: mv: failed to preserve ownership…
Nux
  • 1,028
  • 1
  • 11
  • 13
62
votes
15 answers

How to move 100 files from a folder containing thousands?

I have a directory with thousands of files. How can I move 100 of the files (any files will do) to another location.
gaijin
  • 663
  • 1
  • 7
  • 5
61
votes
3 answers

I've just "mv"ed a 49GB directory to a bad file path, is it possible to restore the original state of the files?

I have (well, I had) a directory: /media/admin/my_data It was approximately 49GB in size and had tens of thousands of files in it. The directory is the mount point of an active LUKS partition. I wanted to rename the directory…
the_velour_fog
  • 11,840
  • 16
  • 64
  • 109
60
votes
6 answers

Quickest way to rename files, without retyping directory path

I know how to rename files in Unix: $ mv ~/folder/subfolder/file.txt ~/folder/subfolder/file.sh ^-------this part------^ ^------this part-------^ It takes too long time to repeat ~/folder/subfolder/file twice. Is there a quicker way?
Hamed Kamrava
  • 6,678
  • 12
  • 35
  • 47
50
votes
4 answers

How can I copy a directory and rename it in the same command?

Currently, I'm running these two commands to create a quick backup of the directory. Is there a way to combine the two commands into one, so that I am copying and renaming the new directory in one command? #cp -R /tf/Custom_App…
AllisonC
  • 691
  • 2
  • 6
  • 8
1
2 3
41 42