Sign in to follow this  
Followers 0
Brubaker

Spaces in file names

9 posts in this topic

I'm trying to script Windows Sysinternals secure delete utility, Sdelete. It works fine so long as the target filename does not contain spaces, but I'm unable to find a way to deal with names that contain spaces. For example:

Run ("Sdelete -p 5 filename.txt") works fine.

Run ("Sdelete -p 5 file name.txt") does not work.

When running Sdelete from a command prompt, I place the filename in quotes: Sdelete -p 5 "file name.txt"

but I haven't found a way to pass the file name (with space) variable in a script. How's it done?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Run("Sdelete -p 5 ""file name.txt""")

Edited by amokoura

Share this post


Link to post
Share on other sites

That works perfectly! Thanks.

Share this post


Link to post
Share on other sites

Run("Sdelete -p 5 ""file name.txt""")

Proper quoting is good.

Another useful trick is to convert it to 8.3 "short" format first:

$sFilePath = "C:\Documents And Settings\" & @UserName & "\Application Data\"
$sShortPath = FileGetShortName($sFilePath)
MsgBox(64, "Result", "Long path = " & $sFilePath & @CRLF & "Short path = " & $sShortPath)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi,

How would one go about using quotes with variables?

I have tried several combinations and nothing is working.

I have this, but it doesn't work, because there aren't quotes around the variable.

Run(GUICtrlRead($IDIEXE_Input))

Thanks,

Kevin

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

How would one go about using quotes with variables?

I have tried several combinations and nothing is working.

I have this, but it doesn't work, because there aren't quotes around the variable.

Run(GUICtrlRead($IDIEXE_Input))

Thanks,

Kevin

This one works for me.

Run("" & GUICtrlRead("" & $IDIEXE_Input))

I don't know any other way.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Here's some examples on using quotes:

$string = """This string has double quotes"""
$string2='"'&"This string too"&'"'
$string3='""""""Lots of quotes :D""""""'
$string4="""this string has many ' ' ' ' and a lot of """""""
MsgBox(0,"",$string&@CRLF&$string2&@CRLF&$string3&@CRLF&$string4)

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Hi,

How would one go about using quotes with variables?

I have tried several combinations and nothing is working.

I have this, but it doesn't work, because there aren't quotes around the variable.

Run(GUICtrlRead($IDIEXE_Input))

Thanks,

Kevin

If you want to Run() the string read from the control ID in $IDIEXE_Input, after putting quotes around it, then it would be:
Run('"' & GuiCtrlRead($IDIEXE) & '"')

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you!!

This works:

Run('"' & GuiCtrlRead($IDIEXE) & '"')

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0