FileItemize error

Started by sidgar, March 22, 2024, 03:17:41 PM

Previous topic - Next topic

sidgar

Hi,

I am writing a script to gather all files in a particular folder. I store the filenames in a variable called prog32, then want to search this list for a certain filename, then remove it. My code is below:

prog32 = Fileitemize("%Dxr32_exe_Path%\*.*")
prog32cnt = ItemCount(prog32,@TAB)

exCNF      = ItemLocate("DRAWERS.CNF",%prog32%,@TAB)
exLGN      = ItemLocate("DXR.LGN",%prog32%,@TAB)

If %exCNF% > 0 Then ItemRemove(%exCNF%,%prog32%,@TAB)
If %exLGN% > 0 Then ItemRemove(%exLGN%,%prog32%,@TAB)

It runs fine until it gets to the "exCNF      = ItemLocate" line, then terminates. The debug logs show the following error:

prog32 = Fileitemize("Z:\jobs\EPSIIA\PROGRAMS\DXR\2013.04\PROGRAM\*.*")
(33734) VALUE UNICODE => DRAWERS.CNF   DXCOURFB.TTF   DXCOURFI.TTF   DXCOURFR.TTF   dxcrush32.dll   dxcrush32.dll.2.config   DXHELVFB.TTF   DXHELVFR.TTF   DXHELVPB.TTF   DXHELVPI.TTF   DXHELVPR.TTF   DXR.CFG   Dxr.chm   dxr.cnt   DXR.LGN   DXR.TIP   DXR001.TTF   DXR002.TTF   dxr32.exe   dxr32.exe.config   DXTIMSPB.TTF   DXTIMSPI.TTF   DXTIMSPR.TTF   dxunzip.dll   dxunzip.dll.2.config   DX_View_EULA_v1.0.htm   FONTINFO.OFS   mfc42.dll   mfc80.dll   mfc80u.dll   mfcm80.dll   mfcm80u.dll   Microsoft.VC80.CRT.manifest   Microsoft.VC80.MFC.manifest   msvcm80.dll   MSVCP60.DLL   msvcp80.dll   msvcr80.dll   MSVCRT.DLL   msvcrt20.dll   stamp.exe   stamp.exe.config   tr01_d50.icm   watermark.enc   xerces-c_2_8.dll   xerces-c_2_8.dll.2.config   zlib.dll

prog32cnt = ItemCount(prog32,@TAB)
(33734) VALUE INT => 47

exCNF      = ItemLocate("DRAWERS.CNF",DRAWERS.CNF   DXCOURFB.TTF   DXCOURFI.TTF   DXCOURFR.TTF   dxcrush32.dll   dxcrush32.dll.2.config   DXHELVFB.TTF   DXHELVFR.TTF   DXHELVPB.TTF   DXHELVPI.TTF   DXHELVPR.TTF   DXR.CFG   Dxr.chm   dxr.cnt   DXR.LGN   DXR.TIP   DXR001.TTF   DXR002.TTF   dxr32.exe   dxr32.exe.config   DXTIMSPB.TTF   DXTIMSPI.TTF   DXTIMSPR.TTF   dxunzip.dll   dxunzip.dll.2.config   DX_View_EULA_v1.0.htm   FONTINFO.OFS   mfc42.dll   mfc80.dll   mfc80u.dll   mfcm80.dll   mfcm80u.dll   Microsoft.VC80.CRT.manifest   Microsoft.VC80.MFC.manifest   msvcm80.dll   MSVCP60.DLL   msvcp80.dll   msvcr80.dll   MSVCRT.DLL   msvcrt20.dll   stamp.exe   stamp.exe.config   tr01_d50.icm   watermark.enc   xerces-c_2_8.dll   xerces-c_2_8.dll.2.config   zlib.dll,@TAB)
(33750) GOSUB Error handler

WIL ERROR SUPPRESSED =>3246 (Ole Object: Object does not exist, or period used instead of a comma)

What am I doing wrong? I've double and triple checked the syntax, made sure there were no misplaced commas or quotes. I want to locate that string inside the list but it seems to fail every time I attempt to use ItemLocate on the prog32 list.

sidgar

Nevermind, I figured it out. I had to remove the %'s inside the ItemLocate() function, and also I had to assign the same list to the ItemRemove() functions, as well as recheck the index after the first value was removed.

spl

seems if you know the folder(s) and filename(s) maybe if fileexist("yourfile") == 1 Then Filedelete("yourfile") and save  the iteration.

[EDIT]
You can ignore the above if your goal was to only remove the filenames from the list and not remove the files.
Stan - formerly stanl [ex-Pundit]