Avoiding DOS space related "path not found errors"

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Avoiding DOS space related "path not found errors"
# 1  
Old 03-08-2013
Avoiding DOS space related "path not found errors"

Well I have a lot of scripts that require dragging and dropping files in order to define Source files etc.

However more often then not it is the case that the path to said file contains NUMEROUS spaces.

I know one way to evade this problem is to encase the path in Quotes like this:

Code:
"C:/Path/to file/"

Sadly it seems that this won't solve all problems related to this.

I recall that it was possible to have DOS recognize Space's in paths and work without a hitch by calling a specific command prior to the path.

Since I could not find said command again:

Any help appreciated.

Last edited by pasc; 03-08-2013 at 12:02 PM..
# 2  
Old 03-08-2013
In this situation I would suggest to use short path.

You can get short path by running:
Code:
dir /x

Or in CLI or batch file you can get them by running:
Code:
for /d %I in (*) do @echo %~sI

# 3  
Old 03-08-2013
The second code will just ouput:
Code:
sI cannot be processed here

# 4  
Old 03-08-2013
Works for me!
Code:
C:\>for /d %I in (*) do @echo %~sI
C:\APACHE~1.27
C:\BD630A~1
C:\Dell
C:\DOCUME~2
C:\DOCUME~1
C:\Drivers
C:\local
C:\oracle
C:\PROGRA~1
C:\Temp
C:\WINDOWS

C:\>VER

Microsoft Windows XP [Version 5.1.2600]

# 5  
Old 03-08-2013
well... it seems that


Code:
for /d %%I IN (*) do @echo %%~sI

works...

STILL a problem remains:

this code cannot be used when the path is like this:
Code:
C:\Program Files\TEST\test it out.png

because the last part is a file...

What do I have to get that to work ?

Last edited by pasc; 03-08-2013 at 12:26 PM..
# 6  
Old 03-08-2013
Code:
C:\>for %A in ("C:\PROGRA~1\TEST\*.*") do @echo %~sA
C:\PROGRA~1\TEST\TESTIT~1.PNG

# 7  
Old 03-08-2013
Oh well, at this point I think it is the best to post the script so you will understand why it is quite hard to implement:

Code:
SET /P SOURCE=Drag and drop the image to be altered (SOURCE):
SET /P toreplace=Drag and drop the pattern to be searched for (MATCH):
SET /P replacingpattern=Drag and drop the pattern that will replace the searched pattern (REPLACE):
set SRC="%SOURCE%"
set SUB="%toreplace%"
set REP="%replacingpattern%"

the variable paths SOURCE, toreplace and replacingpattern are what I need to work with spaces.

You help was quite helpfull so far ! Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

3. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. UNIX for Dummies Questions & Answers

Avoiding "file collision"

I don't know if there's a better name for what I call "file collision"... Basically, I have a script that I'm using for quick and dirty MySQL testing. Here's the idea... #!/usr/local/bin/bash for num in `jot $1` ## Yep, jot... this is FreeBSD do /usr/bin/time mysql --user=root... (2 Replies)
Discussion started by: treesloth
2 Replies

6. Solaris

Solaris9 - qlogic HBAs - luxadm reports "Found path to 0 HBA ports"

Hi All, I'm actually trying to configure a Qlogic HBA on a solaris9 connecting in a Brocade SAN. I installed Solaris9 and now trying to look at FC devices.. bash-2.05# luxadm -e port Found path to 0 HBA ports bash-2.05# luxadm probe No Network Array enclosures found in /dev/es... (7 Replies)
Discussion started by: ilan
7 Replies

7. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

8. UNIX for Dummies Questions & Answers

Same ol "no acceptable cc found in $PATH" but I'm not clueless... just still a noob

Hey All, Let me start out w/ I have serched the forums and found this to be a typical problem. None of the threads have been able to help in my situation though. I know cc or gcc needs to be installed in ...bin]# (or lead the path of the app to wherever gcc is when compiling) so the app can... (4 Replies)
Discussion started by: SloYerRoll
4 Replies

9. Solaris

Network Path Not Found Error "Sunfire V100"

I recently got this new old server from a friend. I just installed a fresh version of Solaris 10 on it. I have put a static IP of 192.168.100.10 the server. Their is no subnetting scheme on the network. And I made the hostname "SunServ." And I also changed the folder "/etc/inet/hosts" because I... (4 Replies)
Discussion started by: louisd11
4 Replies
Login or Register to Ask a Question