mv is a UNIX command to move a file to another directory or rename it.

learn more… | top users | synonyms

54
votes
10answers
74k views

Linux: How to move all files from current directory to upper directory?

I tried something like mv . .. but it doesn't work.
30
votes
5answers
1k views

In bash, how can I rename a file without repeating the path? [duplicate]

Possible Duplicate: Reuse text on a bash command If I want to rename a file a few directories deep, how can I avoid repeating the path? For example: mv path/to/old_filename.txt ...
30
votes
4answers
7k views

What happens if mv is interrupted?

What happens if the Linux mv command is interrupted? Say, I'm moving a whole directory to some other place and interrupt it while it's moving. Will the source directory still be untouched?
15
votes
3answers
600 views

Moving 2TB (10 mil files + dirs), what's my bottleneck?

Background I ran out of space on /home/data and need to transfer /home/data/repo to /home/data2. /home/data/repo contains 1M dirs, each of which contain 11 dirs and 10 files. It totals 2TB. ...
12
votes
2answers
823 views

What happened when i “mv *” no errors shown and now only one folder left. Why?

The comand executed was "mv space *" in a folder with 14GB of data mv * du -hs is the same so where has the 14Gb of data gone ? What have I done?
11
votes
2answers
694 views

mv command confuses directory name with command option

I have a directory called --pycache--, which I need to move to __pycache__. Using the mv command in the following way, gives me the listed output. How can I use the CLI to do what I want? $ mv ...
11
votes
2answers
312 views

Linux mv command moved data to an unknown location?

I accidentally executed this command in SSH: mv /var/www/vhosts/website/httpdocs/magento/* Now all the data in the magento dir is gone. Does anyone know where it moved to? Thanks!
10
votes
2answers
236 views

How to move folder in unix using mv, only when target is on the same drive

I need to move a folder using unix mv command, but only if the target is in the same drive or the same filesystem. What would be the best approach?
7
votes
2answers
12k views

Move files and folders recursively in linux

ls -al ../public-back drwxrwxr-x 4 apache apache 4096 Apr 19 03:32 templates ls -al ../public-back/templates drwxrwxr-x 2 apache apache 4096 Apr 19 03:33 content drwxrwxr-x 2 apache ...
5
votes
1answer
4k views

How to mv a folder in Linux retaining its mtime?

I am using CentOS 5.5 and would like to move a large amount of folders within one volume, retaining their mtime. The best solution I could find is like this: cp -p -r source/data target/ rm -rf ...
4
votes
2answers
1k views

How to move multiple directories, but exclude files in current path with similar name?

Say I have a directory that contains the following: dir1/ dir2/ dir3/ ... dir50/ dir1.txt dir2.txt dir3.txt ... dir50.txt I have been using mv dir* /someotherpath/, then move the *.txt files back. ...
4
votes
4answers
7k views

How to move only files in Unix

How can I move only the plain files (not the directories) from one folder in Linux to another folder using the mv command? I have tried mv * ~/, but it copied everything including the directories.
3
votes
3answers
12k views

Unix Bash rename files using a regex

I would like to rename all files from a folder using a regex(add a name to the end of name) and move to another folder. It my opinion, it should be looking like this: mv -v ./images/*.png ...
3
votes
2answers
3k views

Move a range of numbered files?

I've got 291 numbered files (starting at 001 - title and ending at 291 - title) that need moved into separate directories. (001 to 021 to folder 1, 022 to 053 to folder 2, they aren't necessarily the ...
3
votes
1answer
3k views

mv: inter-device move makes moving a directory to a directory with same name a different operation?

Given: # mv /mnt/hard/git-src/ /usr/portage/distfiles/ mv: inter-device move failed: /mnt/hard/git-src/' to /usr/portage/distfiles/git-src'; unable to remove target: Is a directory ...
2
votes
2answers
675 views

Literate way of moving all files to a new subdirectory

$ mkdir backup && mv * backup/ mv: cannot move `backup' to a subdirectory of itself, `backup/backup' Works, but issues a warning. Also exit code is 1. How to do it properly (but not [much] ...
2
votes
3answers
113 views

I used mv ./*/* to flatten a directory on a ntfs filesystem, without add . to the end of the command, now all of my files are gone

How can I recover these files? I used: mv ./*/* when it was supposed to be mv ./*/* . Now all of my files are gone.
2
votes
2answers
721 views

How can I log the output of the mv command in Linux?

I'm using the command: mv -v -f sourceDir destDir How can I output the verbose console out to a file?
2
votes
2answers
3k views

Using “mv” or “ditto” to merge folders in OS X

Used to the Windows way of doing I just found out OS X has no merge function – moving means replacing the folder. While this does make sense, I miss merging! I've two Wordpress directories, 1 ...
2
votes
3answers
930 views

Move a list of files(in a text file) to a directory?

I have a list of files, with their full paths, one per line in a file "files.txt" I was trying to move all of those files from their original location to a new directory. I CDed into the directory ...
2
votes
1answer
141 views

Bizarre mv operation

The use of a renaming program severely screwed up some of my files. I'm trying to get them back in order. I have file structure like this: ./Hello World/some-filename.ext ./Kitty Parade/another.ext ...
2
votes
3answers
31 views

Move all files in a directory in a subdirectory

I can't find a quick solution for this simple problem: I' ve got this tree: fatherDir -File1.txt -SomeFile.txt ... - A name.txt -sonDir I want to move all the files in fatherDir ...
2
votes
1answer
214 views

Removing a directory containing a file using find

I'm searching a list of directories for certain files and I want to delete the directory that the file is in. This is what I'm trying: find /converter/storage/unmatched/ -size -4b -name '*.mp3' ...
2
votes
1answer
351 views

XCopy on server?

Normally, on my website, files are either handled by WordPress or by me doing FTP. I'd like to copy my entire site to a new folder. I don't want to copy it down to my local drive (with wget) and then ...
2
votes
5answers
2k views

Move all files in sub-directories to current directory?

I've got files in a bunch of subdirectories, and I'd like to flatten them out and move them all to the current directory. I found this question, but adapting the answer to: mv * . didn't work. I ...
2
votes
1answer
140 views

Don't move a directory/file if src and dest are on different partitions

In order to protect myself if I make a mistake in typing a directory/filename path, I am searching for a way to prevent mv from doing anything if the source and destination files exist on separate ...
2
votes
1answer
100 views

I lost a folder that I mv'ed from one partition to another (NTFS, windows) partition - Can I retrieve it using Windows?

I have used the mv command to move a folder from my Linux partition onto my Windows partition (mv /home/FOLDER /media/WINPARTITION/User/Me/Music/FOLDER). I have read a lot now and understand (I ...
1
vote
5answers
2k views

What is the fastest way to move a million images from one directory to another?

I have a million images totally 30gb of disk space that need to move from one local directory to another local directory. What will be the most efficient way? mv? cp? rsync? Something else? ...
1
vote
4answers
2k views

How can i move files with xargs in linux

I am trying this and its not working ls file_* |xargs mv {} temp/ Any ideas
1
vote
3answers
171 views

Moving all files in current directory up one directory

I have installed wordpress onto my CentOS server. Now inside my /var/ww/html folder, I have a wordpress folder. I want to move all the files inside the 'wordpress' folder up into the parent dir, ...
1
vote
2answers
692 views

Moving the home directory to a new drive

I have no more space left on my hard-drive. So I bought a new one and I would like this hard-drive to be the home folder. I thought of copying all the stuff I have on the home folder to the ...
1
vote
4answers
296 views

Replace existing folder with mv command

Apologies if this question has already been asked, I couldn't find anything… Lets say I want to replace 'oldstuff' with 'newstuff'. Basically re-naming to replace. I try using this command: mv ...
1
vote
3answers
297 views

Rename folder using script, variables from excel doc

Linux File System I have a directory with 1500 folders. I am looking to use an excel document that has the 1500 folder names in one column and a unique id in the next. I am looking to script it so ...
1
vote
1answer
380 views

mv - move dir with destination-dir having the same subdirs as source-dir

In FreeBSD (I suppose it works like Linux et al in this regard), I'd like to move src_parent/mydir to dst_parent/mydir. dst_parent/mydir already exists, and it contains some subdirs that's also ...
1
vote
1answer
259 views

How to rename files and subdirectories in bash command line?

In Rails sometimes I need to rename several directories and files, e.g.: app/models/person.rb app/views/persons/_person.haml app/controllers/persons_controller.rb ---- app/models/user.rb ...
1
vote
0answers
68 views

How to rename a folder in Linux?

I want to remove folder aaa and rename folder bbb to aaa. Both have subfolders in them. Seems simple enough using: rm -r aaa; mv bbb aaa However, any subfolders in bbb disappear where I would ...
1
vote
1answer
125 views

Move all files in sub-directories to current directory while renaming duplicates

I have a number of subdirectories and I would like to move any files contained therein to the current directory using a one line Terminal command on the Mac. I know that my file names are not all ...
1
vote
3answers
190 views

mv: cannot move «file.mp4» to «/path/file.mp4»: Device or resource busy*

I simply try to move file to another path and I'm getting mv: cannot move «file.mp4» to «/path/file.mp4»: Device or resource busy* I've tried using lsof, but it's not showing any openfiles. lsof +D ...
1
vote
1answer
48 views

Instead of “mv filename.sql newfolder” I did “mv filename.sql /newfolder” and wiped out a bunch of files?

Like I said, I moved a bunch of sql files but instead of moving them to a directory I seem to have renamed them and put them all in the root directory as one file named "newfolder" Can I undo this or ...
1
vote
1answer
225 views

Issues with mv on windows xp bash shell

As I'm pretty used to the Linux terminal, I set up a bash shell on my Windows XP command prompt by following the instructions in this article: ...
1
vote
1answer
123 views

Move group of files into subdirectory

I want to move some ssh keys into a backup file. Specifically, I want to move id_rsa* into key_backups/, a subdirectory of .ssh. mv id_rsa* key_backup/ gives me back usage: mv [-f | -i | -n] [-v] ...
0
votes
3answers
3k views

Recursive move files of specific type to a specific path

In ~/my/path, I want to move all files that contain string "(J)" and have file type of ".foo" to ~/my/path/j I'm trying: [me ~/my/path]$ find -type f -name "*(J)*.foo" -print0 | xargs mv -0 j/ No ...
0
votes
3answers
350 views

Mac OS: how could I rename a file like APP_001.gif to 01.gif?

I have a load of files in a directory. They all have names like: APP_001.gif APP_101.gif How could I bulk rename them to 01.gif 101.gif i.e. get rid of the prefix before _, and then remove the ...
0
votes
1answer
208 views

Why can't I mv a file?

I followed these instructions to remove Java from my Mac (Lion): http://stikine.wordpress.com/2012/03/02/howto-remove-java/ As part of the procedure, I needed to edit the file ...
0
votes
2answers
476 views

make an alias to move files to a tmp directory

I am trying to create an alias to move files and directories to the tmp directory. This is what I've tried: alias rm='/bin/mv *.* /tmp' The problem is that when I type rm filename, I get an error ...
0
votes
2answers
960 views

How to move all files in a subdir to another dir

I have untar wordpress. It creates a wordpress dir. I want to move the files under this dir to mydomain.com dir but this doesn't work mv wordpress/* mydomain.com What's the syntax then ? Thanks.
0
votes
2answers
46 views

how to use grep and mv together in a directory in shell?

how do you grep the contents of all files in a directory for "TEST" then move those files to a different directory(like the home dir.)?
0
votes
1answer
144 views

Home folder missed after “sudo mv -t /usr/local/src ~/”

My home folder is missing after I run this command sudo mv -t /usr/local/src ~/ How can I recover this?
0
votes
1answer
167 views

Prevent mv from overwriting the larger file by the same name

I need to move all files from a directory, discarding the directory structure. Unfortunately, some files have the same file name (Thumbnails). I'm looking for smth. like this: find /tmp/dirtree ...
0
votes
1answer
169 views

Move files based on list of old and new file paths

What is an efficient way to rename files in OSX/BSD from a text file for files assumed to stay in original folder, but in the format of; /path/old file name.ext\tnew file name.ext There may be ...