|
Answer» Hello everyone. This is my first post on these forums. I have just started a networking certification program, and we are learning the command prompt system. I am having a difficult time with one of the assignments. I am being asked to copy and rename a file to a subdirectory all in 1 step. The syntax of the MOVE command is throwing me off here.
I am in the directory (a subdirectory of my DOCUMENTS) that contains the file I want to move. the file name is sales projections.xls I need to move that file to a subdirectory of the active called FY 2002. I need to rename the file 2002 sales projections.xls
I looked at this site and the help command in the cmd prompt, and I am confused.
I have tried pretty much all permutations and sytax of the below command, but it is not working
move "sales projections.xls" "fy 2002" "2002 sales projections.xls"
Any help you can offer would be appreciated.
Code: [Select]C:\>move /? Moves files and renames files and directories.
To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
[drive:][path]filename1 Specifies the location and name of the file or files you want to move. destination Specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it. [drive:][path]dirname1 Specifies the directory you want to rename. dirname2 Specifies the new name of the directory.
/Y Suppresses prompting to confirm you want to OVERWRITE an existing destination file. /-Y Causes prompting to confirm you want to overwrite an existing destination file.
The switch /Y may be present in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless MOVE command is being executed from within a batch script.
Did you really read the help? Properly?
The file you want to OPERATE on is in the current folder, so just its name will do. It contains spaces so enclose it in quotes.
So the first part (MOVE filename1) will be
move "sales projections.xls"
Now we add a space. Then we build the the second part (destination) . This is the path (relative or absolute) plus, since we are moving and renaming one file, the new filename.
The folder is under the current one, so we (again) can just use its name. It has a space so again we use a quote to start, and we finish the folder name with a slash.
"FY 2002\
Now we can add the new filename and finish with another quote.
2002 sales projections.xls"
Put it all together
move "sales projections.xls" "FY 2002\2002 sales projections.xls"
Thank you for the reply. I did read the help, but apparantly not correctly. Finishing the destination folder name with a \ was throwing me off, as I did not see it in the help file anywhere, and the book for the course did not have an example showing that either. I appreciate you listing the full command for me, as I am very new to reading command syntax.
Thanks again.Quote from: psufan14 on May 29, 2010, 09:35:26 PM Finishing the destination folder name with a \ was throwing me off You need to study path and folder naming.
Ignoring switches, the syntax for just moving a file, while preserving the name is this
move (where the file is now) (where you want the file to go)
example
move "C:\A folder\A subfolder\example file.txt" "D:\New Folder\Sub folder"
The syntax for moving and renaming is essentially this...
move (what the file is now) (what you want the file to become)
example
move "C:\A folder\A subfolder\example file.txt" "D:\New Folder\Sub folder\different name.txt"
If you specify paths or folders then there will be a slash or slashes.
Use the copy command. When you sure you have the correct files, "del" the source files.Quote from: marvinengland on May 30, 2010, 08:30:26 AMUse the copy command. When you sure you have the correct files, "del" the source files.
Actually, Marvin, you have a point there. The OP wrote this
QuoteI am being asked to copy and rename a file to a subdirectory all in 1 step Copying and moving are different things. psufan14, which is it? Quote from: psufan14 on May 29, 2010, 12:59:50 PM I am in the directory (a subdirectory of my documents) that contains the file I want to move. the file name is sales projections.xls I need to move that file to a subdirectory of the active called FY 2002. I need to rename the file 2002 sales projections.xls
Any help you can offer would be appreciated.
We should always offer an example with the output of the example.
C:\test>copy zee.bat c:\test\sub\zoe.bat 1 file(s) copied.
C:\test>cd sub
C:\test\sub>dir Volume in drive C has no label. Volume Serial Number is 0652-E41D
Directory of C:\test\sub
05/30/2010 10:35 AM . 05/30/2010 10:35 AM .. 05/13/2010 10:56 AM 87 zoe.bat 1 File(s) 87 bytes 2 Dir(s) 295,696,343,040 bytes free
C:\test\sub>
The above will copy zee.bat to a subdirectory ( called sub ) and will change the name of the file from zee.bat to zoe.bat. The instructions said to copy the file and in the process rename the file in the new folder. The only command I knew that COULD rename a filewhile moving it was the move command, but I tried a copy command to copy the contents of a directory to another directory and changing the name and that worked as well.
I do need to LOOK at the directory and file switching commands I am very new to that.
|