+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Scripts Thread, Long File Names in Batch File in Coding and Web Development; Hi Everyone I am trying to run the following batch file but keep getting errors. I know its to do ...
  1. #1

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Long File Names in Batch File

    Hi Everyone

    I am trying to run the following batch file but keep getting errors.
    I know its to do with spaces in long file names

    batch file as follows:-

    for /f %%a in (c:\Batch Files and Scripts\ping\c5.txt) do (ping %%a)

    Where would i put the quotation marks?

    Any help would be appreciated

    Thanks

    Barry Stone

  2. #2

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28° 31' 48.89", +28° 25' 37.42" ... if only.
    Posts
    3,255
    Thank Post
    182
    Thanked 375 Times in 304 Posts
    Rep Power
    174
    In place of your first 2 brackets

    "c:\Batch Files and Scripts\ping\c5.txt"
    Last edited by creese; 11th July 2011 at 02:25 PM.

  3. #3

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi Creese

    Tried replacing backet for quotes, still wont run


    Regards

    Barry

  4. #4

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28° 31' 48.89", +28° 25' 37.42" ... if only.
    Posts
    3,255
    Thank Post
    182
    Thanked 375 Times in 304 Posts
    Rep Power
    174
    Is your file extension .cmd or .bat? I also use .cmd

    You could also put a 'pause' command at the end to see if there are any errors when running. Take it off when it runs okay.

  5. #5
    Mcshammer_dj's Avatar
    Join Date
    Feb 2007
    Location
    Portsmouth
    Posts
    944
    Thank Post
    35
    Thanked 165 Times in 133 Posts
    Rep Power
    94
    don't replace the barackets add the inverted commas and keep the brackets

  6. #6

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Creese

    Its .bat


    Barry

  7. #7

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28° 31' 48.89", +28° 25' 37.42" ... if only.
    Posts
    3,255
    Thank Post
    182
    Thanked 375 Times in 304 Posts
    Rep Power
    174
    Quote Originally Posted by barrystone View Post
    Creese

    Its .bat


    Barry
    I prefer .cmd it's more flexible

  8. #8
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112
    9/10 people prefer .cmd

  9. #9


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,053
    Thank Post
    231
    Thanked 2,716 Times in 2,004 Posts
    Rep Power
    794
    Try this instead...

    Code:
    @echo off
    cd /d "%~dp0"
    for /f %%a in (c5.txt) do (ping %%a)

  10. #10

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Authur

    Thanks

    Code works OK

    Regards

    barry Stone

  11. #11

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Thumbs up

    Creese
    Thanks for all your help

    Regards

    Barry Stone

  12. #12

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28° 31' 48.89", +28° 25' 37.42" ... if only.
    Posts
    3,255
    Thank Post
    182
    Thanked 375 Times in 304 Posts
    Rep Power
    174
    Quote Originally Posted by barrystone View Post
    Creese
    Thanks for all your help
    I try :-)

  13. #13

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    1,985
    Thank Post
    114
    Thanked 505 Times in 340 Posts
    Blog Entries
    2
    Rep Power
    286
    Quote Originally Posted by somabc View Post
    9/10* people prefer .cmd
    * who expressed a preference.

  14. #14

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28° 31' 48.89", +28° 25' 37.42" ... if only.
    Posts
    3,255
    Thank Post
    182
    Thanked 375 Times in 304 Posts
    Rep Power
    174
    Quote Originally Posted by jinnantonnixx View Post
    * who expressed a preference.
    So... I am a one in ten.....

  15. #15

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    1,985
    Thank Post
    114
    Thanked 505 Times in 340 Posts
    Blog Entries
    2
    Rep Power
    286
    Quote Originally Posted by creese View Post
    So... I am a one in ten.....
    No, you're one of nine of ten. Keep up now....

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Help with beginner script/batch file to rename Program File?
    By El_Nombre in forum How do you do....it?
    Replies: 3
    Last Post: 23rd June 2011, 02:05 PM
  2. Batch File (select random file) help
    By fil_b in forum Windows Server 2000/2003
    Replies: 5
    Last Post: 5th November 2009, 04:13 AM
  3. Long File and Folder Names
    By karldenton in forum Windows
    Replies: 16
    Last Post: 22nd July 2009, 12:47 PM
  4. Robocopy & long file names
    By cheryl in forum Windows
    Replies: 2
    Last Post: 18th January 2008, 10:27 PM
  5. batch file help
    By beeswax in forum Scripts
    Replies: 9
    Last Post: 3rd March 2006, 07:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •