topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 6:51 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Windows Batchfile can't recognize long file name...!!!!  (Read 41384 times)

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
    • View Profile
    • Donate to Member
Windows Batchfile can't recognize long file name...!!!!
« on: February 09, 2013, 10:53 PM »
Hello folks,
        can anyone provide an answer to these questions, lately i have made few batch file to open portable application and folders, really saves one's bell and i made few winrar files but after playing with it, i realized these batch file would not work for files and folders having spaces and lots of dot between them. Let me give an example:-
       
1.C:\Program Files\Bulk Rename Utility
2.F:\MY SOFTWARE\INSTALL\Microsoft .NET Framework 4.0.30319.zip
3.F:\MY SOFTWARE\INSTALL\Zortam Mp3 Media Studio PORTABLE 14.45.rar     
4.F:\MY SOFTWARE\INSTALL\Auslogics Disk Defrag Professional\diskdefrag.exe


Now Windows batch file would not recognise these type of folders, nor can it open files( of portable application ) with spaces and it can't compress too. Why???
Is their any way round to go about these problem, or do i need to use certain third party software to open or compress these files and folders.
The error i get is:
Windows cannot find
f:\software\Auslogics Disk Defrag Professional\diskdefrag.exe . Make sure you typed the name correctly, and then try again.

So these are the directory structure, the default commands like cd,start, md would not work???

Any suggestion is greatly welcomed.
ClipDiary 5.3/ Smadav 2018/ Some Sense

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #1 on: February 09, 2013, 11:08 PM »
Have you tried surrounding the complete path and filename in quotes?

"C:\Program Files\Bulk Rename Utility"

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #2 on: February 09, 2013, 11:14 PM »
i think i tried that, and i have to recheck that again.
ClipDiary 5.3/ Smadav 2018/ Some Sense

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #3 on: February 10, 2013, 01:25 AM »
As AndyM says, you need quotes around paths that contain spaces - otherwise, the path C:\Program Files\Bulk Rename Utility will be interpreted as launching the program C:\Program Files\Bulk with the two arguments Rename and Utility. It's pretty easy if you can use the full path in your batch files - simply add quotes around the path.

The following all work:
1) "r:\spacy path\fancy program\passwords.exe"
2) "r:\spacy path\fancy program"\passwords.exe
3) "r:\spacy path"\"fancy program\passwords.exe"
4) "r:\spacy path"\"fancy program"\passwords.exe
5) "r:\spacy path"\"fancy program"\"passwords.exe"

...if you have a common "x:\path with spaces" path, perhaps take a look at environment variables ("set /?" in a command prompt).
- carpe noctem

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #4 on: February 11, 2013, 09:50 AM »
If you need to use quote marks, it's possible you may also need to add a widow "title", else Windows can get confused.  If you have problems with a command prompt opening for the batch file, and then hanging, it may help to review this short DC thread: Starting CHS via batch file quandary

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #5 on: February 11, 2013, 10:44 AM »
If you need to use quote marks, it's possible you may also need to add a widow "title", else Windows can get confused.
How quirky, never bumped into that.

Seems like the first quoted argument is taken as window title, even if preceded by any of the other options, and even if it's the full path to an executable. Quirky! (Also, only seems to take effect for console applications?)
- carpe noctem

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #6 on: February 11, 2013, 12:59 PM »
If you need to use quote marks, it's possible you may also need to add a widow "title", else Windows can get confused.

As far as I know, that's only if using the "start" command. "start" takes it's first argument as a window title if that argument is enclosed in double quotes.

So 'start notepad.exe' will start the program notepad.exe, but 'start "notepad.exe"' will open a command window with the title "notepad.exe".

If you want to use "start" to launch a program that has spaces in the filename (or pathname), then you need to quote the filename somehow - if you use double-quotes (there may be other ways to quote the space), then you have to provide a dummy title argument in double quotes.  

  - start "my long program name.exe"     <-- won't work (opens a console window with that as a title)
  - start "" "my long program name.exe"  <-- will work

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #7 on: February 11, 2013, 04:49 PM »
As far as I know, that's only if using the "start" command. "start" takes it's first argument as a window title if that argument is enclosed in double quotes.
I was thinking too much of the other thread, and yes, it was using Start.  I think this situation is poor practice on Microsoft's part.  They should make things clearer.

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #8 on: February 19, 2013, 07:00 AM »
Thank you all for replying to this question, i was well aware of using  " " in between the folder structure containing spaces,
I found few things that didn't work inspite of using " " for opening files and folders.
I really have few folders with spaces that needs to be opened using a bat file,also few programs containing folder structure with spaces.
http://img546.imageshack.us/img546/57/50117515.gif
Windows Batchfile can't recognize long file name...!!!!



Can someone literally try and solver this issue.
ClipDiary 5.3/ Smadav 2018/ Some Sense

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #9 on: February 19, 2013, 07:37 AM »
Unless you've disabled 8.3 naming you can do dir /x at a CLI to get the short name.

C:\>dir /x
 Volume in drive C has no label.
 Volume Serial Number is 0A69-264F

 Directory of C:\

26/07/2012  17:52                24              autoexec.bat
26/07/2012  17:52                10              config.sys
26/07/2012  17:29    <DIR>                       PerfLogs
17/02/2013  21:13    <DIR>          PROGRA~1     Program Files
02/02/2013  17:37    <DIR>                       Users
17/02/2013  21:19    <DIR>                       Windows

eg. progra~1 = "Program Files"

Ergo:

C:\progra~1\aomeip~1 = C:\Program Files\AOMEI Partition Assistant
« Last Edit: February 19, 2013, 08:09 AM by 4wd »

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #10 on: February 19, 2013, 01:38 PM »
hulkbuster: your animated gif shows that you're using the start to (try to) launch stuff with spaces in - as rjbull wrote, you need a quoted "window title" (which is unused for most stuff, so you can just pass "").

For running executables, you should be able to launch a quoted path without using start, unless you need some of the parameters you can use with the start command.
- carpe noctem

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #11 on: February 19, 2013, 07:55 PM »
Playing with the Start command, these will run a program:
Start c:\progra~1\pathto~1\filename.exe
Start "" "c:\program files\path to a program\filename.exe"

These open a new CLI with the title set as given:
Start "c:\progra~1\pathto~1\filename.exe"
Start "c:\program files\path to a program\filename.exe"

The first parameter encountered with quotes is assumed to be a window title.

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #12 on: February 21, 2013, 07:05 AM »
Playing with the Start command, these will run a program:
Start c:\progra~1\pathto~1\filename.exe
Start "" "c:\program files\path to a program\filename.exe"

These open a new CLI with the title set as given:
Start "c:\progra~1\pathto~1\filename.exe"
Start "c:\program files\path to a program\filename.exe"

The first parameter encountered with quotes is assumed to be a window title.

Thank you 4wd, your suggestion really helped and it was something i was really looking to for a solution, and although i go through many suggestion for this post none, seemed to help.....but i am really thankful to those who tried to provide a solution and keeping an open mind, really their were literally 10-15 post's i found through Google and i ended up here for a suggestion that worked. 4wd thank you man, u helped with a solution time and again. Great work , hope you would continue this work for many years to come.....
i have the parent directory containing all the batch files and i set them in the environment variable and use the run feature to run the batch file directly, really saves ones bell.
ClipDiary 5.3/ Smadav 2018/ Some Sense

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,959
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #13 on: February 21, 2013, 11:29 AM »
a message from 4wd :D

Not me, rjbull made it clear back here, (which I must admit I completely overlooked otherwise I wouldn't have posted - sorry rj  :-[ ).



(i reckon he got the wrong thread when posting...)
Tom

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #14 on: February 21, 2013, 05:32 PM »
Unless you've disabled 8.3 naming[/b] you can do dir /x at a CLI to get the short name.
Iirc it's disabled on some recent Windows versions, although I can't remember which - might only be server versions. I thought it was disabled as early as possibly Vista, but just realized I have those nasty peckers on my current Win7 installation - "fsutil 8dot3name set 1" and "fsutil 8dot3name strip" time >_<
- carpe noctem

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #15 on: February 22, 2013, 04:45 PM »
a message from 4wd :D

WTH  :huh:  I'll have to stop reading more than one thread at a time...thanx tomos!

I have those nasty peckers on my current Win7 installation - "fsutil 8dot3name set 1" and "fsutil 8dot3name strip" time >_<

WHS2011 and Win8 also  ;)

paulina

  • Participant
  • Joined in 2015
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #16 on: April 12, 2015, 12:08 AM »
It is usefull software for copy, delete, long path files.
Please try "Long Path Tool" program.

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #17 on: April 12, 2015, 01:43 AM »
It is usefull software for copy, delete, long path files.
Please try "Long Path Tool" program.
VirusTotal
URL:    [deleted because of AbteriX's next post]longpathtool,com/long_path_tool.zip
Detection ratio:    0 / 62  
Analysis date:    2015-04-12 06:25:22 UTC ( 0 minutes ago )
-virustotal.com
2015-04-12_082750.gif


Welcome back, "paulina". Did you forget all of your former usernames?

Long Path Tool may be okay, but the prices? :

2015-04-12_083958.gif
« Last Edit: April 13, 2015, 02:37 AM by Curt, Reason: unlink »

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #18 on: April 12, 2015, 03:44 AM »
What paulina didn't had done, maybe didn't could, did Curt: set a link to that tool so g00gle will increase the reputation of that site.

I see that advertisement for that tool all over the inet. Seems to be a bad tool, if it needs that guerilla marketing by pseudo user comments.


  

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #19 on: April 13, 2015, 10:31 AM »
timing...

Gizmo's "Windows File Name Restrictions – Why a File Name Can be too Long" http://www.techsuppo...-can-be-too-long.htm
vlaurie (Learning About Computers and the Internet) "Naming Windows Files - Restrictions and Limitations" http://vlaurie.com/c.../filenames.htm#table
MSDN "Naming Files, Paths, and Namespaces" https://msdn.microso...5247%28VS.85%29.aspx
-email 'today' from techsupportalert

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,884
    • View Profile
    • Donate to Member
Re: Windows Batchfile can't recognize long file name...!!!!
« Reply #20 on: April 14, 2015, 01:28 AM »
Path Copy Copy adds entries to the Explorer context menu that will grab the short names for you, and it's free open source.

PathCopyCopyContextualMenu.png