Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Cmd.exe


  • Please log in to reply
14 replies to this topic

#1 RandomUser

RandomUser

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 22 September 2007 - 12:54 AM

Having some difficulty renaming a file in my documents using the rename command. I get an error stating that; The syntax for the command is Incorrect. This is using the full path to the filename in XP Pro SP2.

I know this is something simple, but I followed microsoft's guide and it still doesn't work.

BC AdBot (Login to Remove)

 


#2 Sagacity83

Sagacity83

  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Charlotte, N.C.
  • Local time:11:17 AM

Posted 22 September 2007 - 01:52 AM

Hi RandomUser,

If the name of the file you are trying to change is multiple words, you have to put quotation marks around them. And don't forget to put the extensions at the end of the files. for example:

ren "old file.jpg" "new file.jpg" using your file names of course.

Edited by Sagacity83, 22 September 2007 - 01:56 AM.

Gateway GM5076e, Pentium D CPU 3.20GHZ, 2.1GB of RAM, 465GB SATA HDD, NVIDIA GeForce 6200 TurboCache™
256MB, Windows XP Media Center SP2, Mozilla Firefox, McAfee Security Center, AdAwareSE, F-Secure Blacklight, A-squared Free.

#3 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 22 September 2007 - 02:08 AM

rename "C:\Documents And Settings\User02\My Documents\SomeFile.txt" "NewFile.txt"


I've tried that several ways to no avail. I'm wondering if I used the path with system variables only if that would work. This is for a script btw.
Thanks in advance!

#4 Sagacity83

Sagacity83

  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Charlotte, N.C.
  • Local time:11:17 AM

Posted 22 September 2007 - 02:33 AM

Man I wish I was in front of your computer so i could really look at this, anyway, here is something else to think about. If the original file name has a space in between it, you type it that way also. for example.
file name some file.txt
C:\Documents And Settings\User02\My Documents>ren "some file.txt" "newfile.txt"
not saying that you are doing this wrong, just throwing out stuff that can be easily overlooked.

Post exactly what you are typing in so I can see it.
Gateway GM5076e, Pentium D CPU 3.20GHZ, 2.1GB of RAM, 465GB SATA HDD, NVIDIA GeForce 6200 TurboCache™
256MB, Windows XP Media Center SP2, Mozilla Firefox, McAfee Security Center, AdAwareSE, F-Secure Blacklight, A-squared Free.

#5 WinCrazy

WinCrazy

  • Members
  • 265 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Ambler, PA USA
  • Local time:10:17 AM

Posted 22 September 2007 - 09:27 AM

Hi RandomUser.

I realize that the command line command doesn't work, but wouldn't it be a lot simpler to simply rename the file using Explorer ?!

If you are trying to learn how to use the command line, then that's another story.

#6 usasma

usasma

    Still visually handicapped (avatar is memory developed by my Dad


  • BSOD Kernel Dump Expert
  • 25,091 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Southeastern CT, USA
  • Local time:11:17 AM

Posted 22 September 2007 - 12:14 PM

Are you doing this from the User02 account? Could this be a permissions issue (you may not have sufficient permissions to be able to do this)?
My browser caused a flood of traffic, sio my IP address was banned. Hope to fix it soon. Will get back to posting as soon as Im able.

- John  (my website: http://www.carrona.org/ )**If you need a more detailed explanation, please ask for it. I have the Knack. **  If I haven't replied in 48 hours, please send me a message. My eye problems have recently increased and I'm having difficult reading posts. (23 Nov 2017)FYI - I am completely blind in the right eye and ~30% blind in the left eye.<p>If the eye problems get worse suddenly, I may not be able to respond.If that's the case and help is needed, please PM a staff member for assistance.

#7 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 22 September 2007 - 04:28 PM

Hello, Usasma! I'm the permissions/rights guy...


I'm running the command exactly the same on two machines with XP Pro.

Sagacity83, I've already typed shown you what I was typing above. I've also tried that with % value for spaces and I've used the same command with
%windir% in place of C:\ So, the point here is this; I've run the command by the book, and there's bits and pieces left out from the M$ documentation.
It would be nice to have one real world example from the source. Enough said about that.

rename C:\documents and settings\Admin02\My Documents\test1.txt test2.txt
that's exact with the filenames which have NO spaces in them. I also tried that with quotes around both filenames; that's the source and the target.
This and find are the only two commands that are unable to function.

I verified all permissions via ACLS dialogue box, CACLS from the command line, and local computer policy snap in.

Something being entered is incorrect but I don't know what or why.

#8 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 22 September 2007 - 04:33 PM

here's a request.

Sagacity, if you could create the same files with no data in them in the same spot as mine and run the command.
After that, post a screen shot of the outcome from the command line.



PS

WinCrazy, I would be wasting my time if this was just for fun.... as I mentioned, this is for a script.

#9 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:17 AM

Posted 22 September 2007 - 04:49 PM

Check this out:
#1Posted Image
#2Posted Image

Edited by Amazing Andrew, 22 September 2007 - 04:50 PM.


#10 Sagacity83

Sagacity83

  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Charlotte, N.C.
  • Local time:11:17 AM

Posted 22 September 2007 - 04:54 PM

rename C:\"documents and settings"\Admin02\"My Documents"\test1.txt test2.txt

This is it man, I tested it out on my computer using one of my files and everything. Put parentheses around "Documents and Settings" and "My Documents".
Gateway GM5076e, Pentium D CPU 3.20GHZ, 2.1GB of RAM, 465GB SATA HDD, NVIDIA GeForce 6200 TurboCache™
256MB, Windows XP Media Center SP2, Mozilla Firefox, McAfee Security Center, AdAwareSE, F-Secure Blacklight, A-squared Free.

#11 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 23 September 2007 - 01:01 AM

Ok I have one last piece to accomplish here.

I want to run the same command for test1.txt test2.txt and test3.txt changing to 4, 5, and 6. I'd like to do that without iterating through the files with FOR. Microsoft website states that you can perform multiple renames in the context of the same command in the same cmd.exe instance. Further I don't want to use conditional &'to accomplish this....
I know that works but it's not appropriate for the script.

#12 WinCrazy

WinCrazy

  • Members
  • 265 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Ambler, PA USA
  • Local time:10:17 AM

Posted 23 September 2007 - 09:54 AM

Hi RandomUser.

The format of your command is non-standard - move the double quotes to:

rename "C:\documents and settings\Admin02\My Documents\test1.txt" test2.txt

It's a lot easier to type this way. Besides, if you use a .BAT file to execute a command that whole quotes-enclosed string will be interpreted as a single command-line parameter, which is just what you want to happen in a batch file. Since the second parameter has no embedded spaces it will automatically be interpreted by the batch interpreter as a single argument.
_

#13 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 23 September 2007 - 11:42 PM

WinCrazy,

No Offense, but did you read my last post. Have you been paying attention to this thread?
I tried it with the quotes outside and it doesn't work that way. Further I want to use the rename
command three times in the same context.... IE renaming 3 files at the same time in the same rename
command....

something similar to

rename C:\Documents and Settings\Admin02\My Documents\test1.txt test4.txt C:\Documents and Settings\Admin02\My Documents\test2.txt test5.txt C:\Documents and Settings\Admin02\My Documents\test3.txt test test6.txt

But I still get a formatting error...

#14 Sagacity83

Sagacity83

  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Charlotte, N.C.
  • Local time:11:17 AM

Posted 24 September 2007 - 12:03 AM

Renaming multiple files is beyond me. So I'm guessing you was able to rename test1.txt though.
Gateway GM5076e, Pentium D CPU 3.20GHZ, 2.1GB of RAM, 465GB SATA HDD, NVIDIA GeForce 6200 TurboCache™
256MB, Windows XP Media Center SP2, Mozilla Firefox, McAfee Security Center, AdAwareSE, F-Secure Blacklight, A-squared Free.

#15 RandomUser

RandomUser
  • Topic Starter

  • Members
  • 518 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:17 AM

Posted 24 September 2007 - 12:16 AM

yes i was. I could use conditional & statements or for loop, but that wouldn't work on all systems, and may cause headaches on VISTA...

http://www.microsoft.com/resources/documen...s.mspx?mfr=true

check that link and tell me if you can figure out how to rename multiples without running the command 3 times




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users