Sign in to follow this  
Followers 0
johnmcloud

[SOLVED] FileSetAttrib - Variable & Macro

5 posts in this topic

#1 ·  Posted (edited)

Hi guys, i have a question.

Why this work:

FileSetAttrib("C:\Documents and Settings\Windows Xp\Desktop\Test", "+SH",1)

And this not?

$Folder="test"
FileSetAttrib('"' & @WorkingDir & "\" & $Folder & '"', "+SH",1)

Is a limitation or my error?

Thanks for support

Edited by johnmcloud

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only reason that wouldn't work is if @WorkingDir isn't the directory you think it is.

Uh? Is the same directory, i have create a "Test" folder. Take a look:

$NewFolder="Test"
MsgBox(0,0,'"' & @WorkingDir & "" & $NewFolder & '"')

The result is the same dir of the script with full path, so is the same.

Edited by johnmcloud

Share this post


Link to post
Share on other sites

johnmcloud,

You have superfluous quotes in your "file pattern" parameter - try this:

FileSetAttrib(@WorkingDir & "" & $Folder, "+SH",1)

You do not need quotes around variables, only strings. You need additonal quotes around path strings when you pass them to the DOS console using Run(@ComSpec & " /c "....) and they contain spaces - but not with the AutoIt native commands. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

johnmcloud,

You have superfluous quotes in your "file pattern" parameter - try this:

FileSetAttrib(@WorkingDir & "" & $Folder, "+SH",1)

You do not need quotes around variables, only strings. You need additonal quotes around path strings when you pass them to the DOS console using Run(@ComSpec & " /c "....) and they contain spaces - but not with the AutoIt native commands. :)

M23

You have right, i have made the " " becouse i have try without it and not work. The problem was in my script i need to add a Sleep(500) between DirCreate and FileSetAttrib, withuot it i don't know why don't work on my system, maybe becouse the folder has a long name.

Thanks all

Share this post


Link to post
Share on other sites

johnmcloud,

in my script i need to add a Sleep(500) between DirCreate and FileSetAttrib

You have to give the system time to recognize the new folder. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

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

  • Similar Content

    • PEscobar
      How do I get a variable to equal the number entered in a text box?
      By PEscobar
      #Region ### START Koda GUI section ### Form=c:\users\paulo\documents\gui.kxf Global $Form1_1 = GUICreate("Test", 499, 196, -1127, 323) Global $Amount = GUICtrlCreateLabel("Amount", 176, 80, 40, 17) Global $AmountInput = GUICtrlCreateInput("", 224, 80, 57, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $x = This one is just a test, but I want the value of $x to be whatever numbers the user types in. 
    • TheDcoder
      Is it a Good Idea?: $CmdLineRaw as a Macro
      By TheDcoder
      Hello! I am back with another IIAGI? (Is it a Good Idea?)
       
      I think $CmdLineRaw is more like a macro than a "special" variable (which cannot be changed)... So making ti @CmdLineRaw would make more sense and there will 1 less exception to variables , I know that you were wondering about the $CmdLine "special" array... I didn't forgot it, but I don't think a macro can be a array, so I just ignored it... Maybe removing the $CmdLine and changing $CmdLineRaw to @CmdLine would be nice if you ask me .
       
      Think before choosing! TD
       
      P.S Feel free to disagree with me, I want hear your opinion as well .
    • gh0stid
      Autoit problem with $Filename creation please.. help
      By gh0stid
      Hello,

      Sorry to bother you ... but .. I have a problem
      im pretty sure its something you can figure out in least than 5second, but for a reason I just cant get.... I dont.
       
      Look its pretty simple. the script does as follow : search for different folder and subdirectories for NSF files. once found, it log it and copy to to a $storage of my choice .
      the problem is the following, theres is a "IF" if a file with the same name is found, it add _1 to the end of the filename... unfortunately for a reason i just dont get... I cant get it to work if I use anything else than : $Filename = @UserName & $suffixe & ".nsf""
       
      I tried $aFiles $aNSFFiles etc.. nothing work. but @username does the increement..  ( around line 38 )
      thank you ...
    • tauruzian
      Script throw error when run from java code
      By tauruzian
      #include <WinAPIShPath.au3> #include <Array.au3> #include <File.au3> Global $file = "filenamectt.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) Global $line = FileReadLine($file, $i) ;msgbox(0,'', $line) Next FileClose($file) Global $aDays = StringSplit($line, "::") Global $fileName = $aDays[1] ;Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw) WinActivate($fileName) ;MsgBox (0,"Details",$fileName) Send("^c")I used above code to activate my document. It working fine when I run from AutoIt editor, fine when I execute from CMD. When I try to run from my Java project as 
      public void run_getPDFClipPdf1b() { try { // Runtime.getRuntime().exec("C:\\project\\autoit\\PDF_Clip_PDFParam.exe "+param1+""); Runtime.getRuntime().exec("exe\\PDF_Clip_PDFParam_2.exe"); // System.out.println("thread is running..."); } catch (Exception ex) { ex.printStackTrace(); } }it shows error like image below:

      Please advice where I did wrong. 
    • Churchy112
      CSV to Webform
      By Churchy112
      Good morning,
      Apologies if this thread already exists or I've completely missed the answer in a similar thread. 
      I'm new to Autoit since yesterday, albeit that I've had an account for 3 years, I'm only starting to get into it. I am trying to create a script which will read my CSV row by row and create a variable per cell on that row. In my job I'm going to need to fill out a webform 100 times over so I would like to input each variable into my chosen field on this webform and repeat.
      I've been playing with AutoIT and this is what I've done so far, am I on the right track? I was thinking of using the StringSplit functions but I am a bit clueless to be honest. Any help would be Great to get me started.
      #include <file.au3> #include <FileConstants.au3> #include <array.au3> _BrowseForFile() Global $aOutput, $FilePath _FileReadToArray ($FilePath,$aOutput,4,",") _ArrayDisplay($aOutput) Func _BrowseForFile() ;Sets $FilePath global $FilePath=FileOpenDialog("Browse for CSV",@DesktopDir,"csv files (*.csv)",$FD_MULTISELECT + $FD_FILEMUSTEXIST) EndFunc