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

learn more… | top users | synonyms

3
votes
3answers
209 views

How to move subdirectories into another subdirectory within the same directory?

There is a directory dir/. It contains subdirectories a-z. I need to move subdirectories a-y into subdirectory z. If that's hard, then not a-z, but by providing a list of directories that need to be ...
1
vote
1answer
63 views

I've moved my root directory accidentally to a folder, can't figure out how to move it back using busybox [closed]

I've moved my root directory into a website folder in /var/www. Have rebooted my server and am now in a Busybox rescue environment where I have found my root files in the website folder that I tried ...
3
votes
7answers
124 views

find files based on name and moving them with renaming simultaneously

Consider I've directories named according to years and containing pdf files according to subject-code. ls output is: $ ls -l total 32 drwxrwxrwx 1 root root 4096 Apr 8 08:52 May-June-2011 ...
2
votes
2answers
63 views

How to restore a folder that seemingly disappeared after using mv?

I moved/renamed a folder with .svg-figures using mv fig figs. In my mind, this should have renamed the folder 'fig' to 'figs'. Accordingly, the output from ls showed a folder named 'figs' when I ran ...
0
votes
1answer
46 views

command “find … -exec mv …” created a file with strange content

I wanted to move binary files from folder /myhome/sourcedir to /myhome/targetdir. I used a command find /myhome/sourcedir -type f -cmin +3 -exec mv '{}' /myhome/targetdir ';' Folder /myhome/sourcedir ...
2
votes
1answer
51 views

Moving /usr/lib without breaking everything

I want to move this directory in following way: sudo mv /usr/lib /tmp/bad_files/ sudo mkdir /usr/lib sudo mv /tmp/bad_files/lib/* /usr/lib/ Why do I want do do this? I have filesystem-related ...
1
vote
1answer
26 views

File corruption using rsync, multiple rsync processes, moved/renamed source file

I'm encountering some file corruption when using rsync (that is, the file contents do not match the source file). I can understand the file becoming corrupt if it is being written to while being ...
2
votes
2answers
75 views

Make rsync move (not copy) files on local file system

Can I make rsync to move large amount of files instead of copying them when on local filesystem? I would like it to behave like improved mv command. I know about --remove-source-files option but ...
3
votes
3answers
171 views

How do I determine a file's original location?

I used mv to move all files matching a specific pattern into a folder. How can I determine (after moving files) where a specific file came from? Is there any chance of determining the location after ...
3
votes
0answers
51 views

mv to nfs “cannot create regular file … file exists” but creates empty file

I have an automated script that moves data files from the computer that they're collected on to a central NFS server for more general access. I've recently been seeing about 1% of files failing to be ...
2
votes
1answer
84 views

Are there any dangers in using mv (instead of cp followed by rm)?

I'm a graduate student with access to a research group Linux cluster at my university. Over the years, I have accumulated many directories -- I guess "folders" is Windows/Mac terminology? -- in my ...
0
votes
2answers
34 views

mv directory and contents to new directory

I'm sure this is probably a really daft question that may have been answered before (I'm still new to Linux - so sorry in advance), but I've searched high and low and can't find the answer. I have a ...
3
votes
1answer
27 views

Moving sub-directory to new parent directory where the new directory name is incremented by 1

I am attempting to move a sub-directory from one parent directory to another for hundreds of instances, while changing the name of the sub-directory during the move. My directories are a set of ...
1
vote
3answers
60 views

Improve `mv` to require explicit specifying target?

I have hit some errors due to not specifying the target properly when using mv. For details, see: Mistake of using rm What does `mv ./*` without specifying destination do? Can we make mv more ...
1
vote
1answer
40 views

mv to file with

I ran the following mv command, apparently by mistake using backslashes by mistake instead of slashes. mv 2015-02-02_flyer_ppces.pdf ..\PPCES2015\2015-02-02_flyer_ppces.pdf The output is empty. ...
1
vote
1answer
48 views

How directory permissions remain same after mv command?

There are two user A & B. sharing same server. A has created a directory with permission 700 and both user and group are same i.e. user A e.g. drwx --- --- A A temp_dir/ Now user B has ...
2
votes
4answers
82 views

Find and move with exclude

I need to use find and mv together requirement : Need to find all file *.xml but exclude deposit.xml and move it to another folder ( fairly simple) My attempt : mv `find ./*.xml '!' -type d | ...
1
vote
1answer
27 views

Extracting the Contents of tar archive to parent directory issue resulting in creation of sub directories

I have a Tar file: testwebsite.tar I've placed it in the directory I would like to extract its contents to on my Web server which is mytestdirectory I run this command via PuTTY: tar -xvf ...
1
vote
1answer
46 views

Extracting Wordpress.zip file on Linux server

I'm new to Linux and I'm currently trying to do the following: unzip the contents of wordpress-4.1.1.zip to the directory in which it is contained which is /my-test-site/wordpress-4.1.1.zip I ...
1
vote
1answer
91 views

Will `mv` ever have the ability to create directories?

This question asks for the best way to create a directory when using mv if it doesn't exist. My question is why isn't this an inbuilt feature of mv? Is there some fundamental reason due to which this ...
0
votes
3answers
51 views

Renaming multiple Files, Bash Script, preferably with an Addition

Hello you wonderful people, I have a little problem creating a Bash Script. I have 7000 image files (dicoms). These files belong together and should be in order in ONE directory. However, the program ...
1
vote
1answer
32 views

Files missing after using mv and parameter substitution in a loop

Related questions to missing files after mv don't appear to answer my question. The following commands were run within the working directory where the files are located, resulting in missing files. ...
1
vote
2answers
31 views

move content from a folder with unknown name up one directory

I have data arranged as follows: --parent_dir | --4Bz27go1c | -- foo.md -- bar.tar.gz -- baz.c .. I have a parent directory with a known name and a child ...
0
votes
1answer
103 views

rename multiple files with one variable

I am trying to rename one file with one variable. Example: 2014.001.**.**.**.D890.E.m to IP.PMST..BHE.D.2014.001. My script is: #!/bin/bash cd /home/pintolcv/Downloads for jd in {001..366} do ...
1
vote
2answers
104 views

linux/bash equivalent of mv -t

ls -al | grep -v '^d' | xargs mv -t mysubdir I use the above command extensively on Red Hat systems. It moves all files in the current directory to mysubdir $ mv --version Usage: mv [-f] [-i] [-e ...
2
votes
2answers
96 views

Move file to another user's home directory (without sudo)?

I have a couple of files that I want to move to another's user home directory. I don't have permissions to write to that user's home directory, but I know his password. I know how to copy the file ...
1
vote
3answers
56 views

Replace bunch of files maintaining path

I have directory A and B. Each of them contains another directory with item.json inside. Only item.json file is persistent in directories so I cant copy-paste the directories. A: ./path/Item ...
-5
votes
1answer
45 views

How to know where a file was before it was moved [closed]

Why does find match all the files when using it like this? find ~/ "*.pdf" So, I accidentally messed up with my home directory and moved all the files into ~/Documents. Is there a way to undo ...
10
votes
2answers
411 views

Why doesn't the free space on the source partition change during “mv”?

I am running mv to move a directory (which contains many files) from one partition to another. While mv is moving individual files in the directory one by one, I notice that the free space size of ...
1
vote
4answers
1k views

rename multiple files with mv

I want to rename a couple of files in the same directory. When you start to google this there is plenty of help available. What i saw the most if you only want to change the extension is mv *.txt ...
3
votes
2answers
108 views

Atomic removal of directory

Because rename(2) is called by mv, is it safe to assume the following would be atomic? $ mv /home/me/someDir /tmp/toBeDeleted $ rm -rf /tmp/toBeDeleted
0
votes
1answer
33 views

Tried to mv folder, now having trouble finding folder

Yeah, so I was trying to move a folder around, and now I'm having trouble finding it. Originally it was in my .../Downloads/ directory. I did: sudo mv Downloads/Blah/ ~/ ... which seemed to work ...
0
votes
1answer
51 views

Is it a bad habit to move things to tmp?

Im not sure what type of issues this could cause (might be none, of course). But when I had a folder a few days ago that could not be deleted even after running: chflags nouchg -R and then sudo rm ...
2
votes
2answers
336 views

mv command error “already existing file”

I am using a simple script to create some directories. Finding some specific files by name and then moving them into the directories that I have created. The code that I am using is below: mkdir ...
3
votes
0answers
37 views

Rename file with the name from a variable [duplicate]

I want to rename an image with the text in that image. For that I use an OCR and I try to store the name in a variable and use that variable in the mv command but I get mv: target ‘file’ is not a ...
0
votes
2answers
1k views

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

How to replace a text string in multiple files in Linux How to rename multiple files by replacing word in file name? Replace string in files with certain file extension Searching a number of files ...
1
vote
2answers
126 views

mv multiple files same dir without specifying same path or each [duplicate]

If we have a dir/file setup like the following var |-->usr | |-FileA | |-FileB | |-FileC | |-FileD How can I move FileA and FileD without specifying the path twice like in ...
2
votes
2answers
101 views

How to find a specific file and move it to a specific directory?

How to find a specific file, and move it to the specific directory /var/tmp? For example I want to find the file 0914_Jul-2014.gz. Remark, the file 0914_Jul-2014.gz, is under ~300 subdirectories: ...
1
vote
3answers
50 views

Moving files recursively if certain condition is met

I have the following directory tree: records/13/2014.12.16/00/05.mpg records/13/2014.12.16/00/15.mpg records/13/2014.12.16/01/05.mpg records/13/2014.12.16/02/15.mpg records/15/2014.12.14/05/25.mpg ...
2
votes
2answers
77 views

I accidentally moved a directory to '..'. Where did it go?

I accidently left a trailing slash on my directory name when renaming a folder in Linux, mv /images/images/ .. Now the folder has vanished, But I know it's still there due to the space it's using, ...
6
votes
4answers
445 views

Detect if a variable is empty

In my Bash script I have this line: mv -f $HOME_DIR/$dir $HOME_SAVE/BACKUP The problem is when $dir is empty (no $dir directory) the mv command moved the directory $HOME_DIR. We want only to move ...
1
vote
5answers
117 views

How to move a file and change its name without retyping the name and just add the new characters

I change too frequently the location of some files generated daily. The thing is that I want to change their names by only adding the new required characters. What I want is something like this: $ ...
1
vote
1answer
44 views

Linux system files moved, how to return by booting from an installer?

So I accidentally 'sudo mv' my files from /* (root directory) to some directory inside my home directory. My OS stopped working and I rebooted. Then I encountered the error: file ...
1
vote
0answers
44 views

Restore Trash Script not working

I made a script to send a file to a trash folder... echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)" read ans case "$ans" in Yes) echo "$(readlink -f "$1")" >> ...
0
votes
1answer
63 views

Cannot stat error?

Running a "restore" script which moves a file previously deleted (moved to a trashbin folder) back to where it came from. Running the secondary script I receive this error... "mv: cannot stat `test': ...
14
votes
6answers
973 views

How to prevent `mv` from moving a collection of files into a single regular one?

I've just lost a small part of my audio collection, by a stupid mistake I made. :-( GLADLY I had a fairly recent backup, but it was still irritating. Apart from yours truly, the other culprit doing ...
1
vote
1answer
473 views

Rename bash script - false no such file or directory error

I am trying to rename a few hundred files based on another file in the same directory. I found a script and with modification I have the following: while read file; do echo mv ...
4
votes
2answers
240 views

Can multiple mv commands be run in the same directory (race condition)?

I'm moving a large number of files (400K+) from one directory to another and I have the following script to do so (too many files for the mv command to work directly): for file in *; do mv $file ...
25
votes
2answers
1k views

Is it safe to move a file that's being appended to?

I have a node.js process that uses fs.appendFile to add lines to file.log. Only complete lines of about 40 chars per lines are appended, e.g. calls are like fs.appendFile("start-end"), not 2 calls ...
2
votes
3answers
394 views

How to remove file with mv command?

I started to study Solaris in my university. Teacher told me to remove a file with mv command. I tried to move a file to /dev/null. But that did not work. How can I remove file with mv command?