Questions tagged [mv]
mv is a UNIX command to move a file to another directory or rename it.
156
questions
140
votes
11
answers
211k
views
How to move all files from current directory to upper directory?
How to move all files from current directory to upper directory in linux?
I tried something like mv *.*, but it doesn't work.
134
votes
9
answers
598k
views
Move files and folders recursively on Linux
Consider:
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 ...
104
votes
7
answers
79k
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?
44
votes
4
answers
4k
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 path/to/...
37
votes
6
answers
48k
views
Move all files from subdirectories to current directory?
How can I move the files contained in all subdirectories to the current directory, and then remove the empty subdirectories?
I found this question, but adapting the answer to:
mv * .
did not work; ...
25
votes
5
answers
35k
views
How can I move files with xargs on Linux?
I am trying this and it's not working:
ls file_* | xargs mv {} temp/
Any ideas?
25
votes
7
answers
49k
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.
25
votes
4
answers
48k
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 ~/...
22
votes
4
answers
8k
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.
/home/...
17
votes
3
answers
34k
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 ...
16
votes
9
answers
39k
views
What is the fastest way to move a million images from one directory to another in Linux?
I have a million images that takes up 30GB of disk space that need to be moved from one local directory to another local directory.
What would be the most efficient way to do this? Using mv? Using cp?...
16
votes
9
answers
56k
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 ...
12
votes
2
answers
2k
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 --...
12
votes
2
answers
2k
views
What happened when I "mv *"? No errors were shown and now only one folder is left. Why?
The command executed was "mv space *" in a folder with 14 GB of data.
mv *
du -hs
is the same so where has the 14 GB of data gone? What have I done?
12
votes
2
answers
25k
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 ...
11
votes
2
answers
777
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
2
answers
33k
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?
10
votes
2
answers
556
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?
9
votes
2
answers
8k
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 ...
8
votes
1
answer
22k
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
...
7
votes
3
answers
805
views
bash move file relative to its position
As the title says, can I move a file relative to its current position?
Let's assume I am in the root directory, with the following file structure:
...
├──home
└──user
├──Documents
└──...
6
votes
4
answers
3k
views
Move files from subdirectories into single directory and prefix original directory name
I have a directory structure like this:
./a/1.png
./a/2.png
./a/3.png
./b/1.png
./b/2.png
./b/3.png
./c/1.png
...
And I want to take all the files in the subdirectories and move them to a new ...
5
votes
3
answers
5k
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. ...
5
votes
3
answers
4k
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 ...
4
votes
3
answers
20k
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 ./test/*...
4
votes
2
answers
22k
views
mv: target 'XXX' is not a directory
I am trying to write a bash script that will go through a directory
and rename the files (the file name is really crazy and is not recognizable to any human as what they are) to "Chapter1.mp3&...
4
votes
3
answers
24k
views
Linux mv command for moving multiple files with different extensions
I am wondering if it possible to use bash to mv multiple files with different extensions into one directory, for example
mv 1.png 2.jpg dir/
except match many files
3
votes
4
answers
8k
views
How to batch rename files by removing special character without using rename in linux shell
For example, I have 100 files and their names all have blank space. One of them is "The Monkey King Return (2015).mkv".
How to remove all blank in name and replace with dot character, also remove "("...
3
votes
1
answer
1k
views
Bash move and rename by parsing the output of find
I have nested directories of pdf files and I would like to extract them to a higher level directory renaming them as follows:
My files are something like:
./path1/pathA/fileI.pdf
./path1/pathB/...
3
votes
2
answers
1k
views
mv deleting files at the end instead of one by one
I am moving a folder recursively between two filesystems using mv -v.
It seems like deletions happen at the end (in order to make mv transactional ?). I don't have enough space to hold two copies of ...
3
votes
1
answer
1k
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' -...
3
votes
3
answers
252
views
How to copy or move files -n levels up on OSX via shell
How can I find all files of certain type/name and copy them -n levels up? Here is the filesystem tree structure:
germany/
|
adventure/
|
300x600/
...
2
votes
3
answers
1k
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, ...
2
votes
2
answers
1k
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
3
answers
198
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
1
answer
172
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
1
answer
2k
views
mv command - how it works?
I was moving big sized directory (upto 10gb) using mv command and after some minutes I cancelled it (Ctrl+C).
The mv process was then stopped and some of the files were copied to the destination ...
2
votes
3
answers
6k
views
mv command reports "X and Y are the same file", cifs filesystem
I'm trying to get a script that will rename and move videos. Here is what I have:
#!/bin/bash
src="/mnt/Files_Apps/temp/"
dest="/mnt/Files_Apps/TFTP root/"
for file in "$src"*.*; do
newfile="${...
2
votes
1
answer
1k
views
how to make mv ignore when renaming directory with the same name
I have a for loop on which I have directories that the mv command will apply the same name to its directories, other directories have different names, for example:
for i in {1..3};do
mv hg/ hg
done
...
2
votes
1
answer
1k
views
Where did my files go after using mv command?
All my .c source files and a Readme file were in a subdirectory called assignment2 in a directory called Assignment2. Originally, from assignment2 directory:
$ ls
corrupt.c decode.c encode.c fix.c ...
2
votes
2
answers
4k
views
Renaming a file with mv: "cannot move to a subdirectory of itself"
I'm trying to rename a file using the regular mv command which has worked countless times before.
$ ls -l |grep "Picture 001"
-rwxrwxrwx 1 rolf rolf 657711 Feb 19 21:42 Picture 001_19.jpg
$ mv "...
2
votes
1
answer
2k
views
Cannot move ./test to a subdirectory of itself, './test/test'
When trying to convert some files to lower case I noticed something which seems strange to me.
When executing this in bash:
find . -iname 'test' | while IFS='\n' read item; do mv $item $(echo $item |...
2
votes
2
answers
500
views
User moved root directory into subdirectory, or tried to, machine unresponsive
A particularly special user of mine inadvertently ran a command to move files that looked something like this:
mv /* /home/ubuntu/GS14K/
This led to a series of errors:
mv: cannot move /bin' to /...
2
votes
2
answers
569
views
Moving all files from one folder to upper folder
I was searching the answer to question how to move files from one folder to upper folder and nowhere I have not found the answer mv name/* .
Why I can't use this to moving files to upper folder? The ...
2
votes
1
answer
874
views
What are the rsync equivalent command/s to mv /a/b /c/d?
What are the rsync equivalent command/s to mv /a/b/ /c/d/, i.e, to move a directory tree from one location to another, possibly on another file system?
That is, not just copy, but delete the files ...
2
votes
3
answers
1k
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
1
answer
1k
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
1
answer
156
views
How does this find state actually work in moving a file up one directory?
Can someone explain how the string manipulation in this find statement actually works? My head is about to explode trying to figure it out. :-o
From: UNIX shell scripting: how to recursively move ...
2
votes
4
answers
2k
views
bash extract first number from filename
I'm trying to move files like this:
...
DLG023-00-01-sprite.TextGrid.json
DLG023-00-01.prosody.json
DLG023-01-01-sprite.ogg
DLG023-00-02-sprite.TextGrid.json
DLG023-00-02.prosody.json
DLG023-01-02-...
2
votes
1
answer
255
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 ...