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

learn more… | top users | synonyms

1
vote
0answers
35 views

Cannot mv to a subdirectory of itself

I am running this simple script and I am trying to create a cron job so that the file gets copied to my thumbdrive (with the new name) sudo cp /home/pi/NewLog.log /media/usb sleep 20 cd ...
1
vote
1answer
19 views

mv command with path wildcard containing random string

Im trying to move a file to a path which has a random string that I cannot know in advance ~/.config/foldername/45fhiu84.dev-edition/subfolder/ I have tried mv ~/Downloads/myfile.txt ...
1
vote
2answers
36 views

how to move set of files in one-liner [duplicate]

I wanted to move 1000 files in a directory to another dir. I can do it if I'm in the original dir but if I try this mv $(ls /home/jeremy/source|tail -1000) /home/jeremy/dest from elsewhere, the ...
1
vote
1answer
41 views

cp vs. mv: which operation is more efficient?

I find myself moving reasonably large amount of data (20+ GB) from one directory tree to other. Often times they are on the same filesystem but sometimes they are on different ones. I do cp just to ...
0
votes
1answer
24 views

Adding prefix to the largest numbers filename

So I have a list of files that have numbers similar to the example below: /list/CAP_0045.dat /list/CAP_0044.dat /list/CAP_0046.dat I want to rename the file with the largest number to add a prefix ...
0
votes
1answer
36 views

Lost file when renaming it

I wrote a shell script to rename a whole bunch of files. Unfortunately, I accidentally saved it with Windows EOL so it messed up the file names with control-m characters at the end of each file. I ...
0
votes
1answer
23 views

Broken files after moving them back and forth [closed]

I have different partitions for / and ~, both with ext4 filesystems. In ~, I have a folder with many files, I tried to move the complete folder to the root partition mv ~/folder /folder/ In the ...
1
vote
0answers
22 views

How to remove a single quote from a file name? [duplicate]

I have some podcasts on my radio server which contain a timestamp when they should be played. I noticed one of them is put into single quotes 'filename.mp3', and I'm unable to remove them. Check this: ...
0
votes
1answer
46 views

mv misbehaves in shell script [closed]

I have the following folder structure: /backup /backup/copy.sh /backup/archive/ /backup/20160405_logs/ /backup/20160405_logs/sql.log /backup/20160405_logs/bak.log I want to move the folder ...
1
vote
2answers
35 views

Copy/move group files with renaming

I want to copy (or move) some files like cp ./patt*.py /other/path. However /other/path/ already contents files with the same names. So, I would like copy with renaming (adding some suffix, for ...
0
votes
1answer
15 views

Moved .mov to wrong directory and now it is a Unix Executable File [duplicate]

Was moving a movie file using mv but I typed the directory wrong. It turned my movie file into a Unix Executable File. mv /path/to/folder/1/this.mov /path/to/folder2 /folder2 did not exist Can I ...
4
votes
4answers
524 views

Why can't mv deal with existence of same-name directory in destination?

mv can't move a directory to a destination with a same-name directory: $ mv fortran/ imperative_PLs/ mv: cannot move ‘fortran/’ to ‘imperative_PLs/fortran’: Directory not empty Why does mv not ...
1
vote
1answer
52 views

Move specific directories from certain depth

I've tried to make a bash script that will help me move specific subfolders from my folder. The issue is,in the main folder photos I have folders named like this: 1,2,3,4,5,6,7,8,9,0 and inside them ...
-4
votes
1answer
39 views

how to move all files under one directory to home directory

I have the script files script1.ksh ...script10.ksh in the directory star2 PATH : home/aaa/star2 I need to move all the files under star2 to the home directory (home/aaa) NOTE : I do not want the ...
-2
votes
3answers
60 views

Move files based on filename into directory Year/Month/Day

I have files in the format YYYY_MM_DD_HH:MM:SS.swf that dump into a folder /home/user/dump/ I want to move these files into a new directory tree /home/user/save/year/month/day/ based on the ...
2
votes
2answers
46 views

How to recover multiple files which has been moved into one?

I was trying to rename (mv) few of my files and ran a wrong loop resulting into renaming all the 10 files into one. Now I can see only one file whereas there should have been ten files. How do I ...
0
votes
1answer
25 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 ...
1
vote
4answers
47 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 ...
5
votes
5answers
278 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
560 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
30 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
100 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
66 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 ...
13
votes
5answers
1k 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
59 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 ...
1
vote
5answers
171 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
80 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
27 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
85 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
97 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
517 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
125 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
146 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
38 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 ...
6
votes
2answers
246 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
108 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 ...
29
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
171 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
1k 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
291 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
3k 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
38 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
76 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
83 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
38 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
187 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
131 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
39 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 ...