germ Posted March 3, 2015 Share Posted March 3, 2015 I searched but couldn't find anything so I'll just ask. Is there a known "bug" that most Autoit file functions don't handle "non-traditional" filenames? LIke file/folder names that contain characters such as spaces, parentheses "()" and commas? I need to manipulate literally thousands of files with non-traditional names and none of the file functions seem to work. Functions like get file attributes and copy folders just puke and die. An example file name would be like "XX YYYYY-10 ZZ Metals (11111111's).pdf" And if there is a known bug, how about a quick and easy work around? Link to comment Share on other sites More sharing options...
spudw2k Posted March 3, 2015 Share Posted March 3, 2015 (edited) I can't seem to reproduce the problem (at least in my quick testing). Does this script fail for you? $hFile = FileOpen("XX YYYYY-10 ZZ Metals (11111111's).txt", 2) FileWrite("XX YYYYY-10 ZZ Metals (11111111's).txt", "test") FileClose($hFile) $sAttribs = FileGetAttrib("XX YYYYY-10 ZZ Metals (11111111's).txt") ConsoleWrite($sAttribs & @CRLF) FileCopy("XX YYYYY-10 ZZ Metals (11111111's).txt","test.txt") Edited March 3, 2015 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 Of course it works. This doesn't, but I know for a fact the folder does exist. The code tells me it doesn't. #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Func Example() Local $sFilePath = "E:\0 Cert Folders\M11111 11111111-3" If IsFile($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file.") Else MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file.") EndIf EndFunc ;==>Example Func IsFile($sFilePath) If FileExists($sFilePath) Then Local $str = FileGetAttrib($sFilePath) MsgBox($MB_SYSTEMMODAL, "", "<" & $str & ">") Else MsgBox($MB_SYSTEMMODAL, "", "not found <" & $sFilePath & ">") EndIf Return StringInStr(FileGetAttrib($sFilePath), "D") = 0 EndFunc ;==>IsFile Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 It's "hit and miss". Some folders can be interrogated, others fail. Thanks for replying. Link to comment Share on other sites More sharing options...
SadBunny Posted March 4, 2015 Share Posted March 4, 2015 Well, it's hard to troubleshoot without a reproducer. Can you come up with an example path that actually fails, so others can try and reproduce? Also, what version of Windows are you running exactly and what kind of filesystem are you working on? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 its your return, clean that up and all should be fine #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Func Example() Local $sFilePath = @ScriptDir & "\0 Cert Folders\M11111 1111111-3" If IsFile($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file or folder.") Else MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file or folder.") EndIf EndFunc ;==>Example Func IsFile($sFilePath) If FileExists($sFilePath) Then Local $str = FileGetAttrib($sFilePath) MsgBox($MB_SYSTEMMODAL, "", "<" & $str & ">") return 1 Else MsgBox($MB_SYSTEMMODAL, "", "not found <" & $sFilePath & ">") return 0 EndIf EndFunc ;==>IsFile ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 Thanks but it says the folder isn't there when it really is. Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 (edited) apologies...it worked prior to slapping all that stuff back in and the kids walking through the door, promise. I'll fix it back It works in my testing, I will try and break it. Edited March 4, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 If the folder exists, why would the code I posted tell me it's not found? No need for apologies. I guess I'm doing something horribly wrong, but I don't see it? Link to comment Share on other sites More sharing options...
kaisies Posted March 4, 2015 Share Posted March 4, 2015 FileExists() returns true if a file is there OR a folder is there. You should not be using this to determine if something is a file or folder. Use DirGetSize() to determine this. afaik DirGetSize() requires a trailing "". could be wrong. Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 (edited) this works, *with an added msgbox so you can verify that it is the fileexist failing and not your return still being 0 while your example is not going to tell you its a file until you let the return be 1 when you find a match. #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Func Example() Local $sFilePath = @ScriptDir & "\0 Cert Folders\M11111 11111111-3" If IsFile($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file.") Else MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file.") EndIf EndFunc ;==>Example Func IsFile($sFilePath) msgbox(0, '' ,"File Exists = " & fileexists($sFilePath)) If FileExists($sFilePath) Then Local $str = FileGetAttrib($sFilePath) MsgBox($MB_SYSTEMMODAL, "", "<" & $str & ">") return 1 Else MsgBox($MB_SYSTEMMODAL, "", "not found <" & $sFilePath & ">") return 0 EndIf EndFunc ;==>IsFile Edited March 4, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 FileExists() returns true if a file is there OR a folder is there. You should not be using this to determine if something is a file or folder. Use DirGetSize() to determine this. afaik DirGetSize() requires a trailing "". could be wrong. Read the code. I'm not. Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 this works, *with an added msgbox so you can verify that it is the fileexist failing and not your return still being 0 while your example is not going to tell you its a file until you let the return be 1 when you find a match. #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Func Example() Local $sFilePath = @ScriptDir & "\0 Cert Folders\M11111 11111111-3" If IsFile($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file.") Else MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file.") EndIf EndFunc ;==>Example Func IsFile($sFilePath) msgbox(0, '' ,"File Exists = " & fileexists($sFilePath)) If FileExists($sFilePath) Then Local $str = FileGetAttrib($sFilePath) MsgBox($MB_SYSTEMMODAL, "", "<" & $str & ">") return 1 Else MsgBox($MB_SYSTEMMODAL, "", "not found <" & $sFilePath & ">") return 0 EndIf EndFunc ;==>IsFile You missed the point. In the code I posted the folder is there. The code tells me it isn't. Some folders works - others don't. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 4, 2015 Share Posted March 4, 2015 (edited) Bothose's code works for me. Are you sure the script is located in the root folder above the subfolders "0 Cert FoldersM11111 1111111-3"? EDIT: Post a sample of a file folder path and name that are failing. And stop using bold face, it looks like you're shouting all the time. Edited March 4, 2015 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
germ Posted March 4, 2015 Author Share Posted March 4, 2015 My script is on the C: drive All the files I'm looking at are of the E: drive. I can't post the actual folder name for various reasons. But it is there. Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 (edited) wait wait.... i just realized what you are trying to say in boldface, rather than easy reproducers. The problem is the evaluation of the stringinstr return. not the fileexists. I would msgbox(0, '' , IsFile($sFilePath)) If that is the area that is telling you it is/is not a file and confirm that the evaluation is correct. #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Func Example() Local $sFilePath = @ScriptDir & "\0 Cert Folders\M11111 11111111-3" ;~ $sFilePath = @ScriptDir & "\MOVI0001.avi" If NOT stringinstr(IsFile($sFilePath) , "False") Then MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file.") Else MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file.") EndIf EndFunc ;==>Example Func IsFile($sFilePath) If FileExists($sFilePath) Then Local $str = FileGetAttrib($sFilePath) MsgBox($MB_SYSTEMMODAL, "", "<" & $str & ">") Else MsgBox($MB_SYSTEMMODAL, "", "not found <" & $sFilePath & ">") EndIf Return StringInStr(FileGetAttrib($sFilePath), "D") = 0 EndFunc ;==>IsFile Edited March 4, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kaisies Posted March 4, 2015 Share Posted March 4, 2015 (edited) Read the code. I'm not. Edited March 4, 2015 by kaisies Link to comment Share on other sites More sharing options...
BrewManNH Posted March 4, 2015 Share Posted March 4, 2015 Your code, as posted in post #3, works for me if I create a folder with that name and search for it. There's nothing wrong with the code, it's working fine as-is, for me. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now