Jump to content
Sign in to follow this  
saywell

Attribute setting problem

Recommended Posts

saywell

I've written a script to change file attributes, which sounds simple - and I've used something less complex without problems.

This one lets you choose what to change in terms of attributes and folders, but i keep getting a failure to change attributes message and i can't work out why!

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=U:\Icons\Print602_233.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****




Global $flag, $path 
Global $att = InputBox ("Select Attributes", "Enter attributes to change in standard format eg:"  & @CR & "+A, +RA-SH" & @CR & @CR & "Options are:" &  @CR & "R = READONLY  A = ARCHIVE   S = SYSTEM   H = HIDDEN   N = NORMAL" & @CR &   "O = OFFLINE   T = TEMPORARY "," ","",400,200)

Global $params = '"' & $att & '"'
$params = StringUpper ($params)
$params = StringStripWS ($params, 8)

Global $Extension = InputBox ("Choose File extension", "Enter file extension without dot eg bmp" & @CR & @CR & "* for all files")


Global $folder = FileSelectFolder ("Select Folder", @HomeDrive,6)

$path = '"'& $folder & '\*.' & $Extension & '"'

Global $Recurse = MsgBox (35, "Recursive?", "Apply to all subfolders?" & @CRLF & "YES to recurse, NO to apply to selected folder only")
; yes = 6, no = 7, cancel = 2
Select
    Case $Recurse = 6
        $flag = 1
    Case $Recurse = 7
        $flag = 0
    Case $Recurse = 2
        Exit
EndSelect



MsgBox (4096, "Command", $path & "," & $params & ","  & $flag)

If Not FileSetAttrib ($path, $params, $flag) Then
  MsgBox(4096,"Error", "Problem setting attributes.")
EndIf

Grateful to anyone who can spot my silly mistake!

Thanks,

William

Share this post


Link to post
Share on other sites
PsaltyDS

Drop the double quotes around things you are passing to AutoIt functions:

Global $params = $att

; ...

$path = $folder & '\*.' & $Extension

:graduated:


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
saywell

Thanks, PSaltyDS!

I thought it was something silly. I thought the parameters that had " around them in the 'written' version would need them in the programmed version, but obviously that's not the case. Another lesson learned...

Regards,

William

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.