Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: wat is wrong in the syntax?  (Read 5984 times)

0 Members and 1 Guest are viewing this topic.

srujana

  • Guest
wat is wrong in the syntax?
« on: November 01, 2011, 02:08:52 AM »
the below code is working to move File.txt from Input folder to OutPut.

@echo off
chdir c:\InPut
dir /B > File.txt
move File.txt c:OutPut
pause

But when i try to move that to desktop, its telling error as
"the syntax of the command is incorrect".like below

@echo off
chdir c:\InPut
dir /B > File.txt
move File.txt %userprofile%\Desktop\
pause

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: wat is wrong in the syntax?
« Reply #1 on: November 01, 2011, 06:20:06 AM »
Have you checked the value of the %userprofile% variable? It probably contains space(s) which require you to use quotes.

Code: [Select]
@echo off
chdir c:\InPut
dir /B > File.txt
move File.txt "%userprofile%\Desktop"
pause

 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

bobsklarservices



    Beginner

  • Time is of the essence.
  • Thanked: 2
    • Certifications: List
    • Experience: Experienced
    • OS: Other
    Re: wat is wrong in the syntax?
    « Reply #2 on: November 01, 2011, 07:40:38 AM »
    If using Windows XP, it definitely contains spaces, as it contains "Documents and Settings"
    Work to be all you can be. You define your limits!

    NewCNCguy



      Starter

      Re: wat is wrong in the syntax?
      « Reply #3 on: December 02, 2011, 08:40:29 AM »
      Thanks Sidewinder - I made the same rookie mistake.

      Salmon Trout

      • Guest
      Re: wat is wrong in the syntax?
      « Reply #4 on: December 02, 2011, 11:56:40 AM »
      Anyhow, the OP has cancelled his or account...

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: wat is wrong in the syntax?
      « Reply #5 on: December 02, 2011, 12:03:12 PM »
      her...
      " Anyone who goes to a psychiatrist should have his head examined. "

      Salmon Trout

      • Guest
      Re: wat is wrong in the syntax?
      « Reply #6 on: December 02, 2011, 12:06:33 PM »
      her...

      I had "his or her account" in my brain but my fingers typed "his or account".


      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: wat is wrong in the syntax?
      « Reply #7 on: December 02, 2011, 02:20:29 PM »
      I knew that...
      " Anyone who goes to a psychiatrist should have his head examined. "