Jump to content

Spaces in file names


Recommended Posts

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?

Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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

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

Link to comment
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!

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...