Questions tagged [mv]
mv is a UNIX command to move a file to another directory or rename it.
156
questions
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 ...
0
votes
2
answers
7k
views
Creating a tar with a absolute path
tar -cf /Users/Files/myfile.tar /Users/Files/
I am basically trying to create a tar containing the contents of User/Files and create it in the folder of the contents.
I can only execute this process ...
0
votes
1
answer
254
views
mv in script eports "cannot stat"
I'm trying to write a script that adds the last accessed time to the end of the basename. Here is the script:
for f in *.doc; do
DIR=$(pwd)
FILENAME="$f"
FILETYPE=${FILENAME##*.}
...
1
vote
3
answers
11k
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.)?
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
└──...
0
votes
2
answers
2k
views
Moving files with extension from source to destination
Hello i am trying to move all files with .hi and .o extension from a target folder /src to another folder /Obj
So far i have tried:
srcpath=$(pwd)"/src"
ghc src/Main.hs > Logs/output....
134
votes
9
answers
599k
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 ...
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 "...
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?
0
votes
2
answers
183
views
Moving all pwd contents to pwd's parent directory?
Another user asked about this and I'm looking for clarification because apparently I can't comment until I have 50 pts.
One of the given answers for moving everything(including hidden items) up a ...
0
votes
1
answer
848
views
Unable to use mv with wildcards in Mac OS X
I am trying to use the command
mv ./?*20?* new_directory
running ls ./?*20?* gives multiple matches, but the above command gives me
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n]...
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/...
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.
0
votes
4
answers
2k
views
Keep SSH connection alive when moving large folder
Context :
I have a web server (my hosting provider is OVH).
I have a large folder with many files in many sub-directories (100k+ files).
I need to move this directory from one place to anuther on ...
0
votes
1
answer
126
views
Unix mv *.* moves also subdirectory
I have a main directory main_dir and subdirectories v1, v2, v3 all containing the same files. I rename v3 : mv v3 v3_old and recreate it mkdir v3. My jobs then create the files in main_dir.
Up to this ...
0
votes
0
answers
66
views
How to copy one user's directory and overwrite onto anther users directory
Env : Centos7
User A's directory : /home/A/dir
User B's directory : /home/B/dir
/home/A/dir's content(sub directories) :
a b c
/home/B/dir's content(sub directories) :
a b c d e f
My goal and ...
1
vote
1
answer
223
views
What to do when *nothing* will stop a mv command that did not finish
See screenshot. As you can see, I've tried all the things that I've read about to use. Nothing can kill this dang mv command.
The last line with "mv: failed" has been there for 12+ hours, ...
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 ...
2
votes
0
answers
22
views
How to change directories recursively in huge files
I tried to copy data between two huge NFS folders. I copied all the data, but I noticed that by mistake I made duplicate directories only in the 6th depth.
For example, instead of copying:
/mnt/nfs1/a/...
0
votes
3
answers
490
views
Moving files only linux
I have a path /participant/data where all the files are in the data directory.
However, I want the directory-structure to be /participant/data/subdirectory, with subdirectory containing all the files. ...
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="${...
1
vote
1
answer
7k
views
sed: cannot rename ./sed6x9apB: Operation not permitted using docker-compose with WordPress image
WordPress container fails to start when using docker-compose, where there are existing WordPress files, aborting with the following error:
sed: cannot rename ./sedtpghTB: Operation not permitted
...
0
votes
2
answers
3k
views
How to check what was moved when using “mv” and the process stops due to permissions issues?
I want to move a folder (test) on our server from /home/data to /home/projects/data. What I did is to use mv.
It did not move the folder in the end for some permission problems. However, the folder ...
1
vote
1
answer
178
views
Ubuntu mv Command turned folder in file with unknown details
I moved a folder using mv and now my folder is a file with unknown details.
The command I ran was mv juno-projects/ juno. After running this command juno is a file not a folder and more than that the ...
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&...
1
vote
2
answers
5k
views
Remove a word from file names on Linux
I accidentally ran exiftool -all= * on my Linux system in my Downloads folder (the command removes the EXIF metadata from all files in the current directory). Luckily, exiftool creates backup files by ...
0
votes
0
answers
163
views
My user home directories disappeared after a move command
I was trying to move some files and following a post here on the forum I ran the follow command, but an error came and I hit Ctrl+C and my /desktop /documents /music folders and its contents are gone....
0
votes
0
answers
80
views
How to prevent interrupted mv moving data
On Ubuntu 18.04 I am running a small PHP web application which moves directories one by one with nested dirs and files from one filesystem to another via exec(mv filepath) method.
Now I have the ...
0
votes
2
answers
2k
views
Best method (mv/cp) to replace an active file in linux?
I am making a script for updating a text include/conf file for an active service. The script will first write changes to a temp file. When done, to replace the include file with the temp file, ...
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
...
1
vote
1
answer
2k
views
How to move all subdirectories into the parent folder in bash?
Suppose, I have a parent folder which includes 4 sub-folders. Each of the sub-folders can have a different number of subfolders (let's call them sub-sub-folders). How do I move all sub-sub-folders ...
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 ...
0
votes
1
answer
3k
views
“The system cannot find the path specified” error in Jupyter Notebook
I have been given a Jupyter Notebook which was made on a Linux computer and now I'm trying to get it to work on my Windows home computer. The problem comes when using the !/bin/mv command.
I have ...
1
vote
1
answer
41
views
Shrink filename (remove last N columns)
I want to remove from this filename last 3 columns
david@david-ThinkPad-E480:~/Downloads$ ll A*
-rw-rw-r-- 1 david david 16006720 сен 9 11:03 'A.Matrosov. E.Rodionov. S.Bratus. Rootkits and Bootkits. ...
0
votes
2
answers
286
views
Using MV to rename image files using a script
I am trying to rename a set of Tiff images 001, 001 x, 002 , 002 x sequentially.
I am looking for the script to name image 001, 002, 003 and so on
This is the script I am running.
num=1
# Rename ...
-1
votes
2
answers
7k
views
Move multiple directories at once, how?
In directory_1, I have numerous subdirectories with names consisting only of digits, and some of these need to be moved to directory_BB:
directory_1
3245561
8978554
2345556
3453456
6873253
...
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; ...
0
votes
1
answer
669
views
While doing mv from one disk partition to another disk partition, my files are deleted, is there any way i can retrieve it?
I mounted /backup partition by adding another disk than ran a command in /backup1 directory which is the part of root partition which belongs to old disk.
I ran this command - mv * /backup/
Now, my ...
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 ...
0
votes
1
answer
114
views
Move only a certain sub-directory to a new folder with shell script
I have a folder Accounts containing mail accounts, all of these folders have a folder Archive.folder. I want to move all of archive folders with a simple script to a new folder.
I tried this so far:
...
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 "("...
0
votes
1
answer
904
views
Find and rename forward slash in directory name (Linux / OmniOS)?
On a fileserver at work, we have a bunch of old directories made on macOS (that was previously on an AFP share) that has / in the name. I would like to replace / with -, but am having a hard time ...
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 ...
0
votes
1
answer
30
views
mv all files with different extention to a new directory with new filename and same extention
could anyone tell my how I could make a script for moving files (filename given but all possible extentions) to another new directory with new filename but same extentions.
f.e. (dir or filename ...
0
votes
0
answers
232
views
Lost my files while moving on AWS S3
I used the command on CLI -
aws s3 mv s3://<source_directory_path> <destination_directory_path> --recursive
aws s3 mv s3://<source_directory_path> s3://<...
0
votes
2
answers
898
views
When moving a directory into another directory, is there a simple way to generate a failure when the target directory doesn't exist?
I had a habit of using mv directory1 directory2/ thinking that if I mistyped the name of directory2 it would fail and warn me the directory didn't exist. As it turns out, that's not the case.
Is ...
0
votes
1
answer
62
views
Added files and folders gone after MV run
I ran mv /folder1/folder2/folder3/ /folderA/FolderB/FolderC/. Then I added more files and folders to /folder1/folder2/folder3/ during the move. It seems all of the files I added after I started the mv ...
0
votes
4
answers
2k
views
Linux: moving files from different directories with same name into one while renaming them
I batch-ripped my old CDs to Track1.mp3. The problem is Each CD directory has Track1.mp3 so when I move them to /Music, they overwrite!
Is there possibly a bash script or mv command to move .mp3s ...
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?...
1
vote
1
answer
76
views
Move a range of numbered files and change their value
I've got numbered files (DSC_0001.jpg to DSC_0065.jpg), I know how to move them with mv DSC_{0001..0065}.jpg dir.
I have no idea how to move them and change the range of values.
mv DSC_{0001.....