Questions tagged [mv]

mv is the Unix command to rename or move a file or directory.

mv is the Unix command to rename or move a file or directory.

Syntax:

mv - move (rename) files

Examples:

mv /my/dir /my/other/dir

References:

Related commands

625 questions
11
votes
2 answers

Is there an scp variant of mv command?

I am writing a script that will move files from a local system to a remote system. It must do so through an encrypted channel like ssh. What is the best way to do this? I can perform this in two steps like: scp *.jpg user@ip: rm *.jpg But, that…
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
11
votes
1 answer

Which HDFS operations are atomic?

I am trying to write code to import files into HDFS for use as a hive external table. I have found that using something like: foo | ssh hostname "hdfs dfs -put - /destination/$FILENAME" can cause a type of error where a temporary file is created…
Setjmp
  • 27,279
  • 27
  • 74
  • 92
10
votes
3 answers

Moving All Files From Directories One Step Up

I have a directories that look like this fool@brat:/mydir/ucsc_mm8> tar -xvf *.tar…
neversaint
  • 60,904
  • 137
  • 310
  • 477
10
votes
2 answers

Find files, rename in place unix bash

This should be relatively trivial but I have been trying for some time without much luck. I have a directory, with many sub-directories, each with their own structure and files. I am looking to find all .java files within any directory under the…
ThePerson
  • 3,048
  • 8
  • 43
  • 69
9
votes
4 answers

How to move all files with fewer than 5 bytes in BASH?

I have a folder containing many audio files, but some are ~4 bytes and seem to contain nothing, they are 0 seconds long and have no sound. I want to move them to a folder called "temp/". How can I move all of the files in the folder that have fewer…
Village
  • 22,513
  • 46
  • 122
  • 163
8
votes
3 answers

mv: invalid option -- '0'

How can I rename files with "-" in front of the filename, for example: "-0001.jpg" Everyime I try to run: for i in *; do mv "$i" "${i//-/}"; done or: for i in *; do mv "$i" "${i#*-}"; done I got this error: mv: invalid option -- '0' Try `mv…
Roger
  • 8,286
  • 17
  • 59
  • 77
8
votes
4 answers

Move only files recursively from multiple directories into one directory with mv

I currently have ~40k RAW images that are in a nested directory structure. (Some folders have as many as 100 subfolders filled with files.) I would like to move them all into one master directory, with no subfolders. How could this be accomplished…
user1067257
  • 443
  • 3
  • 6
  • 15
7
votes
2 answers

Glob renaming in bash

I'm fairly new to bash so sorry if this is kind of a basic question. I was trying to rename a bunch of mp3 files to prepend 1- to their filenames, and mv *.mp3 1-*.mp3 didn't work unfortunately. So I tried to script it, first with echo to test…
wim
  • 338,267
  • 99
  • 616
  • 750
7
votes
1 answer

How to pass a variable to the mv command to rename a file text with spaces and the variable's text in a bash (.sh) file

I create a variable and store the day, date & time in it: NOW=$(date "+%a %d/%m/%Y% %H:%M") Then I would like to pass $NOW to the mv command to rename a file. e.g. Create file named a.txt with a title and the current date: printf "File Report (" >…
joshuatvernon
  • 1,530
  • 2
  • 23
  • 45
7
votes
2 answers

mv command goes crazy

Here is the script and I have singled out the block that I believe is causing the recent problem mv sourcefile targetfile > /dev/null I know for a fact that mv will by default overwrite without asking for confirmation if the destination file…
Srini V
  • 11,045
  • 14
  • 66
  • 89
6
votes
3 answers

What is the advantage of Model-View-Controller (MVC) over Model-View?

Could anyone give an example of why it would be advantageous to use MVC instead of a simpler Model and a View only. Note: whether it's called MVC or MVP (Model-View-Presenter), I'm talking about the one where the View receives input, then the…
Saleh Al-Abbas
  • 155
  • 1
  • 10
6
votes
5 answers

Moving Files and Folders Accidentally to Non-existent Places

I often do the command such as: mv folder $something_that_does_not_exist mv files* $something_that_does_not_exist Then, I realise that my files are gone. I cannot see them even in the folder "$something_that_does_not_exist". Where have my files and…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
6
votes
1 answer

Use of regex in bash with mv

I have 4 files to rename: ./01: I0010001 I0020001 ./02: I0010001 I0020001 I want to add auxiliary filename .dcm to each file, so I have tried: $ mv \(*/*\) \1.dcm mv: cannot stat '(*/*)': No such file or directory $ mv \(./*/*\) \1.dcm mv:…
Erik Apostol
  • 65
  • 1
  • 1
  • 5
6
votes
1 answer

mv a file that contains spaces from a shell script

I am trying to mv a file (rename it to replace spaces with dashes). If I pass the source and dest arguments without quotes, the source is broken up because mv thinks it is the end of the argument. If I surround source and dest with arguments, mv…
user2021539
  • 949
  • 3
  • 14
  • 31
6
votes
2 answers

Executing 'mv A B': Will the 'inode' be changed?

If we execute a command: mv A B then what will happen to the fields in the inode of file A? Will it change? I don't think that it should change just by changing the name of the file, but I'm not sure.
Luv
  • 5,381
  • 9
  • 48
  • 61
1 2
3
41 42