Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Move and Rename in One Command Post 302971021 by ayylmao12 on Thursday 14th of April 2016 10:47:12 PM
Old 04-14-2016
Move and Rename in One Command

Hey all, I really need help with some homework I'm having on UNIX. This probably sounds stupid, but I'm being asked to move a file to a specific directory and rename it a specified name in one command. I know how to do it in more than one command, I just can't seem to figure it out using only one command. I'm using Solaris OS if that matters at all. Thanks!
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move files and rename ??

1. If I have a file-yyyymmdd.dat in a directory DATA1, then how do I move this file to directory DATA2 and the file name change to file-yyyymmdd.dat.currenttime I can manual do this $mv fileA-yyyymmdd.dat ./DATA2/fileA-yyyymmdd.dat.`date +%Y%m%d%H%M%S` but how do I move all of the files in... (1 Reply)
Discussion started by: sabercats
1 Replies

2. Shell Programming and Scripting

Move and rename files in seq. with padded digits

Greetings, I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out. (9 Replies)
Discussion started by: rocinante
9 Replies

3. UNIX for Dummies Questions & Answers

Using Rename to move files

I am connecting to a remote server (Unix) and doing a ftp dowmload of files. The script (VB script) works fine except for not being able to move the downloaded files on the remote server to another folder. I need to move all files with an .asc extesnion from folder "tovecellio_edi" to folder... (1 Reply)
Discussion started by: snufse
1 Replies

4. Shell Programming and Scripting

Script move and rename based on matching criteria

Hi all, i would like to create a script that move and rename files from all the subdirectories of a given directory to others subdirectories of the same directory based on "matching" criteria in the "from" and "to" parameters. Example: Begin script from /home/test/1_T_2008* move to... (3 Replies)
Discussion started by: braidomik
3 Replies

5. Shell Programming and Scripting

Rename/Move files and schedule the script

Hello, I'm new in the forum and in UNIX scripting, what I need is to write a simple batch script that renames or move the files back & forth from one directory to another, and then schedule the script to run on the server when the scheduled down time is, which is on Thursdays at 8pm and during... (5 Replies)
Discussion started by: dannyghost
5 Replies

6. Shell Programming and Scripting

Need to move and rename a list of files

Hi, I need to do something easy but I can't seem to figure out how to do this. Let's say I have 6 files in the directory below: /ebsbeta_f/flash/EBSUATQB/onlinelog o1_mf_6_55klt7nr_.log o1_mf_3_55klskj4_.log o1_mf_4_55klsrl1_.log o1_mf_5_55klt09p_.log o1_mf_2_55klv1ts_.log... (10 Replies)
Discussion started by: exm
10 Replies

7. Shell Programming and Scripting

Windows Power Shell - rename files and move

hi people; i want to make a file/folder operation as follows. - i have 41 folders in Windows and each of them have same-named files (~200 files each) inside. - i want to stack these files together in a folder but Windows is asking to "overwrite" (as usual) since the file names are the same.... (2 Replies)
Discussion started by: gc_sw
2 Replies

8. UNIX for Dummies Questions & Answers

Rename files in a directory and move them

I have a directory e2e_ms_xfer/cent01 this contains the multiple files some of which will be named below with unique date time stamps e2e_ms_edd_nom_CCYYMMDD_HHMM.csv What I want to do is in a loop 1) Get the oldest file 2) Rename 3) Move it up one level from e2e_ms_xfer/cent01 to... (1 Reply)
Discussion started by: andymay
1 Replies

9. Shell Programming and Scripting

How to rename (move) most recent files in directory?

I'm using cygwin32 on Windows. DN is an environment variable pointed at my download directory. This command works to move the single most recent file in my download directory to my current directory: mv "`perl -e '$p = $ARGV; opendir $h, $p or die "cannot opendir $p: $!"; @f = sort { -M $a... (2 Replies)
Discussion started by: siegfried
2 Replies
mv(1)							      General Commands Manual							     mv(1)

NAME
mv - move or rename files and directories SYNOPSIS
extarg] file1 new-file extarg] file1 [file2 ]... dest-directory extarg] directory1 [directory2 ]... dest-directory DESCRIPTION
The command moves: o One file (file1) to a new or existing file (new-file). o One or more files (file1, [file2, ...]) to an existing directory (dest-directory). o One or more directory subtrees (directory1, [directory2, ...]) to a new or existing directory (dest-directory). Moving file1 to new-file is used to rename a file within a directory or to relocate a file within a file system or across different file systems. When the destination is a directory, one or more files are moved into that directory. If two or more files are moved, the desti- nation must be a directory. When moving a single file to a new file, if new-file exists, its contents are destroyed. If the access permissions of the destination dest-directory or existing destination file new-file forbid writing, asks permission to over- write the file. This is done by printing the mode (see chmod(2) and Access Control Lists below), followed by the first letters of the words yes and no in the language of the current locale, prompting for a response, and reading one line from the standard input. If the response is affirmative and the action is permissible, the operation occurs; if not, the command proceeds to the next source file, if any. If file1 is a file and new-file is a link to another file with other links, the other links remain and new-file becomes a new file. If file1 is a file with links or a link to a file, the existing file or link remains intact, but the name is changed to new-file which may or may not be in the directory where file1 resided, depending on directory path names used in the command. The last access and modification times of the file or files being moved remain unchanged. Options recognizes the following options: Perform commands without prompting for permission. This option is assumed when the standard input is not a terminal. Causes to write a prompt to standard output before moving a file that would overwrite an existing file. If the response from the standard input is affirmative, the file is moved if permissions allow the move. Specifies the handling of any extent attributes of the files(s) to be moved. extarg can be one of the following values: Issue a warning message if extent attributes cannot be preserved, but move the file anyway. Do not preserve extent attributes. Do not move the file if the extent attributes cannot be preserved. If multiple source files are specified with a single target directory, will move the files that either do not have extent attributes or that have extent attributes that can be preserved. will not move the files if it cannot preserve their extent attributes. Extent attributes cannot be preserved if the files are being moved to a file system that does not support extent attributes or if that file system has a different block size than the original. If is not specified, the default value for extarg is Access Control Lists (ACLs) If optional ACL entries are associated with new-file, displays a plus sign after the access mode when asking permission to overwrite the file. If new-file is a new file, it inherits the access control list of file1, altered to reflect any difference in ownership between the two files (see acl(5) and aclv(5)). In JFS file systems, new files created by do not inherit their parent directory's default ACL entries (if any), but instead retain their original ACLs. When moving files from a JFS file system to an HFS file system or vice versa, optional ACL entries are lost. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text as single byte and/or multibyte characters. and determine the local language equivalent of y (for yes/no queries). determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of If any internationalization vari- able contains an invalid setting, behaves as if all internationalization variables are set to See environ(5). International Code Set Support Single character and multibyte character code sets are supported. EXAMPLES
Rename a file in the current directory: Rename a directory in the current directory: Rename a file in the current directory whose name starts with a nonprinting control character or a character that is special to the shell, such as and (extra care may be required depending on the situation): Move directory and its contents to a new location in the file system (upon completion, a subdirectory named resides in directory Move all files and directories (including links) in the current directory to a new location underneath Move all files and directories (including links) in to a new location underneath and are in separate directory paths): WARNINGS
If file1 and new-file exist on different file systems, copies the file and deletes the original. In this case the mover becomes the owner and any linking relationship with other files is lost. cannot carry hard links across file systems. If file1 is a directory, copies the entire directory structure onto the destination file system and deletes the original. cannot be used to perform the following operations: o Rename either the current working directory or its parent directory using the or notation. o Rename a directory to a new name identical to the name of a file contained in the same parent directory. DEPENDENCIES
NFS Access control lists of networked files are summarized (as returned in st_mode by stat(2)), but not copied to the new file. When using on such files, a is not printed after the mode value when asking for permission to overwrite a file. AUTHOR
was developed by AT&T, the University of California, Berkeley and HP. SEE ALSO
cp(1), cpio(1), ln(1), rm(1), link(1M), lstat(2), readlink(2), stat(2), symlink(2), symlink(4), acl(5), aclv(5). STANDARDS CONFORMANCE
mv(1)
All times are GMT -4. The time now is 07:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy