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

learn more… | top users | synonyms

0
votes
1answer
29 views

files disappear when I run mv command [on hold]

I use the below command to move files mv *.gz directoryname but directory name has a spelling mistake and the file with directory name has been generated with unknown format. And I lost my file. ...
0
votes
1answer
21 views

File -> ../../archive/folder/file restore

Hi i'm new to Linux and I need to use it temporary to set up LetsEncrypt. Once complete, I needed to move the /etc/letsencrypt/live/fullchain.pem file into the root dir but i moved the file ...
0
votes
4answers
38 views

Rename files randomly but without repetition

Suppose i have a folder with a lot of file names some very strange and nonsense I want to rename it like File-1 File-2 File-3 .. I have tried this(echo is for tryng) for name in *; do echo mv ...
4
votes
4answers
145 views

Rename folder with odd characters

I have a folder on my Mac called "␀␀␀␀HFS+ Private Data". I'm trying to delete it but it contains a bunch of odd characters that are choking unlink, rm and mv, making it difficult to remove it and ...
7
votes
7answers
542 views

How to rename splitfile[a-z] to splitfile[1-26]

I am trying to rename files named in the form of splitfile[a-z] to splitfile[1-26].csv, that is I want to rename splitfilea to splitfile1.csv and so on. I tried the following command: mv ...
0
votes
0answers
25 views

What is the effect of rsync with -E and --chmod?

Reading through a script I came across an rsync command with the following flags: -rtlDE -c --delete-after --chmod=u+rwX,go-rwx /path/to/dir1/ /path/to/dir2/ Background: I am refactoring the ...
0
votes
2answers
62 views

mv: No such file or directory error even though directory most certainly exists

I am attempting to do the very simple task of moving file.gz from /home/username/Downloads/file.gz into /mnt/gentoo/proc/ When I issue mv /home/username/Downloads/file.gz /mnt/gentoo/proc/ it returns ...
2
votes
2answers
64 views

How to definitely move a file without overwritting anything

Is there a command or option that will allow me to move files without overwriting anything? For the sake of argument, let us call the file foo.rar. Now the -n sort of works, it won't overwrite the ...
12
votes
5answers
872 views

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 ...
2
votes
1answer
43 views

What happens when multiple processes try to mv the same files between two different filesystems

I accidentally launched 32 processes (one process per core on my virtual machine) to mv some files between two ext4 filesystems, but only some of them were successfully mv'd: for i in `seq 1 32`; do ...
2
votes
5answers
145 views

List (or move) only files with a certain number of lines?

Dealing with a whole bunch of two-line config files, I'd like a way to exclude any files that have a different number of lines. So, something like: mv * destdir only if file contains exactly two ...
0
votes
2answers
38 views

File Transfer from Unix to Windows network shared location

How can I move the files from unix path to windows network shared path and the file should be moved to respective folder in shared path and if not then it is to create a folder based on file name and ...
0
votes
0answers
24 views

Error: rm /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: no such file or directory

I have a small sh that rename 2 files. However, when I try to download the file generated, I got the error: Error: /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: open ...
2
votes
4answers
82 views

Move files/table following selection criteria

Considering a variable a describing temperature series for the city a. I have 9 directories (a1, a2, a3, a4, a5, a6, a7, a8, a9) each of them containing a table (respectively a1.txt, a2.txt, a3.txt, ...
3
votes
4answers
92 views

Moving a list of files by matching them to a destination index

Say I have two text files src.txt and dest.txt, where src.txt contains a list of filenames (some of which include spaces) in /src/dir/ and dest.txt contains, in random order, a list of the complete ...
3
votes
3answers
436 views

How do I pipe the output of tar through mv?

A previous question of mine asked how to pipe downloaded files through tar, now I would like to know how to pipe the output of tar through mv. See I have this command at the moment: wget -c ...
2
votes
1answer
85 views

Bash script unable to move files

I'm trying to write a "janitor" script that will run as a cron job in one specific directory. It is supposed to create an archive folder with the date of creation in the name, and then find and move ...
1
vote
3answers
131 views

Move files up by a directory by depth criteria

I have a directory tree that looks like this (simplified, in truth there are hundreds of folders): . ├── a │   └── b │   └── a.h5 ├── b │   ├── b │   │   └── e.h5 │   └── c │   ├── a.h5 │   ...
1
vote
3answers
37 views

Moving certain files to new location (and appending the datettime)

I have two Directories: /routea/path/to/dir1 /routeb/path/to/dir2 in dir1 I have some files: file.name file.name.1 file.name.2 file.name.3 (There may be more than the 4 files). I need to move ...
7
votes
2answers
236 views

Move files back by 2 directory

$ cat file /tmp/foldera/folderb/folderc/file1 /tmp/folderc/folderd/foldere/file2 /tmp/folderf/folderg/folderh/file3 Need to move this files to /tmp/foldera/ /tmp/folderc/ /tmp/folderf/ ...
4
votes
1answer
88 views

mv overwrites read-only file without prompting

The GNU Coreutils manual for mv says: If a destination file exists but is normally unwritable, standard input is a terminal, and the -f or --force option is not given, mv prompts the user for ...
28
votes
5answers
2k views

What is the point of mv -f

The GNU Coreutils manual for mv says: -f --force Do not prompt the user before removing a destination file. However, this already seems to be the default behaviour for mv, so the -f option appears ...
1
vote
1answer
166 views

Why does this rename operation not work? [duplicate]

This works: $ touch abcdefg $ mv -v abcdefg abc[de]fg ‘abcdefg’ -> ‘abc[de]fg’ But this doesn't work: $ touch abcdefg $ mv -v abcdefg abc[d]efg mv: ‘abcdefg’ and ‘abcdefg’ are the same file ...
4
votes
3answers
557 views

“mv” file with garbled name by inode number?

I have several files with encoding issues in their file names (German umlauts, burned on CD with Windows, read by Windows and synced to Linux with Seafile. Something, somewhere went wrong...). Bash ...
0
votes
0answers
14 views

How to copy files which includes spaces [duplicate]

I have the code below: for i in *.pdf; do mv $i books/; done This line of code selects file by words not the whole file name, so when it tries to move "The code of valamor.pdf" it gives the output ...
3
votes
1answer
170 views

mv: cannot remove directory: Directory not empty

Running the command /data/jritchie$ mv ~/jenkins_dev /data/jritchie/jenkins_dev I'm getting a bunch of errors like the following: mv: cannot remove ...
2
votes
2answers
1k views

Why do I get permission denied when using mv althrough directory rights are correct?

I get permission denied when trying to move folder Music via mv although directory owner is set to my user and user permissions are set to 7. What's going on? (I know that I could use sudo but I want ...
0
votes
1answer
30 views

Replace some characters in a certain part of a filename

On Solaris, I've got a script that succesfully do that: USER,REPORT_NAME,DD:MM:HH24.pdf -> USER,REPORT_NAME,DD_MM_HH24.pdf The one-liner is this: for f in *:*; do mv "$f" $(echo "$f" | tr ':' ...
3
votes
2answers
63 views

How to format a file while moving?

I have 2 directories. SOURCE and DESTINATION. I am moving the .csv files from source to destination as mv -f SOURCE/*.csv DESTINATION/ While moving, I want to remove the first and last line from ...
4
votes
3answers
62 views

Move unique files from a folder with duplicates files

Well to put it simply, I have duplicate files in a folder, with this form: file.ext file(1).ext file(2).ext file(3).ext otherfile.ext otherfile(1).ext otherfile(2).ext ... I want to move only ...
0
votes
2answers
72 views

rename multiple directories by adding one character [duplicate]

I have multiple folders named as follow: Name1 Name2 ... Name9 Name10 Name11 ... I need to rename them using mv command into: Name01 Name02 ... Name09 Name10 Name11 ...
0
votes
2answers
34 views

mv files into folders based on numbering in names

I have 30 folders: s-01 s-02 ... s-30 And, I have 30 files: txtFile-001 txtFile-002 ... txtFile-030 How can I perform the following operation in one shot mv txtFile-001 s-01/txtFile mv ...
3
votes
2answers
111 views

Move a file and replace it by a symlink

Can someone give me a command that would: move a file towards a new directory and leave a symlink in its old location towards its new one
3
votes
6answers
103 views

Rename first part of multiple files with mv

In a directory there are these files and more: file1.txt file1.html file1.pdf ... Every file1 should be replaced with newfile: newfile.txt newfile.html newfile.pdf ... I've tried: for f in ...
0
votes
1answer
29 views

Overwrite file from old folder to new folder

I have 2 folder: - /Desktop/old - /Desktop/new In old folder, I have following file: - olda.txt - oldb.txt In new folder, I have following file: - newa.txt - newb.txt - newc.txt And I want to ...
1
vote
2answers
179 views

What command should I use to move these particular elements?

Here is my initial situation: In a folder named for example Father, are stored some files in the following way: Father contains 24 children folders (let's call them Child1, Child2, ...), and each one ...
1
vote
1answer
83 views

Batch renaming of files with ascending number

I have a batch of files: $ ls Li1Fe1O2_11 Li1Fe2O3_8 Li1Fe3O4_2 Li1Fe3O4_5 Li2Fe1O3_16 Li2Fe2O4_12 Li3Fe1O4_19 Li3Fe1O4_22 Li1Fe1O2_14 Li1Fe2O3_9 Li1Fe3O4_3 Li1Fe3O4_6 Li2Fe1O3_17 Li2Fe2O4_13 ...
1
vote
1answer
15 views

Only move folders not existing in target directory

I am looking for a way to move folders that are not already present in the target directory on my linux server. Example: Target directory folder1 folder2 folder3 folder4 Source directory folder1 ...
1
vote
1answer
110 views

Can't find folder after mv command

I was working on a backend, and decided to make a git repository for the whole app. After cloning into my home directory, this is the list of commands: ~$ mv PartySpotBackend /PartySpot mv: cannot ...
4
votes
1answer
64 views

Is it possible to add a password to moving or copying specific files on Linux?

I have a directory setup very nicely(i.e organized with READMEs and easy navigation etc.). I would like people to be able to access the files in this directory maybe even copy them to their own ...
4
votes
3answers
107 views

How to remove space in all sub directories in shell script?

I tried following shell script to remove all spaces with underscores: find $1 -depth -name "* *" -print0 | \ while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done If I have a directory ...
7
votes
2answers
2k views

How to replace spaces in all file names with underscore in Linux using shell script?

I tried following shell script which should replace spaces from all xml files for xml_file in $(find $1 -name "* .xml" -type f); do echo "removing spaces from XML file:" $xml_file mv "$xml_file" ...
0
votes
2answers
2k views

File exists but mv errors out with: “mv: cannot stat ‘file.tar.gz’: No such file or directory”

I am creating a script in Centos 7 to move the latest file within a directory to another directory. The original directory that I'm copying from contains a valid file, however when I try to move or ...
1
vote
1answer
26 views

Deny permission to move a soft link

I have a soft link that was accidentally moved as a result of a user drag/drop operation in a Filezilla UI. Is there a way to prevent a user from moving the link but leaving all other permissions ...
0
votes
1answer
32 views

Folder organization

I have several folders ("amazon", "niger", "rhine",...). Inside each of them I have several subfolders ("gfdl", "hadgem", "ipsl",...). Each subfolders is composed by 5 subfolders (e.g. in "amazon", ...
0
votes
1answer
68 views

Operation of “mv” described in “Advanced Programming in the UNIX Environment”

In Advanced Programming in the UNIX Environment (book) Section 4.14, interpret the i-node and directory, there is a paragraph: When renaming a file without changing file systems, the actual ...
2
votes
2answers
162 views

Rename a set of files with pattern <name>.1.gz.html to <name>.html

I tried to use the command: mv *.1.gz.html *.html But, I got the response: <filename> is not a directory. How can I get this working? I tried the rename command as well, but, I couldn't ...
2
votes
2answers
65 views

What's the appropriate way to do “mv ./* ./subdirdir/”? [duplicate]

Under the current directory I have a number of files, and one directory. I would like to move all files to the sub directory: mv ./* subdir/ cannot move ./subdir to a subdirectory of itself... The ...
1
vote
1answer
130 views

Move files from multiple directories to another system

Let's suppose I have a folders in the source system: AB1, AB2, AB3. And I have the same folder names AB1, AB2, AB3 in the destination system. I want to move AB1 files to AB1 and AB2 files AB2 and ...
5
votes
2answers
519 views

Why does renaming a file with mv command alter an inode's “change” date & time?

A file hello.c is renamed to hi.c. As the output of stat command shows, [change] time stamp has been changed. usually it is changed when inode of file got modified. Why renaming with mv command ...