![]() |
Killing files - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Killing files (/showthread.php?tid=3734) Pages:
1
2
|
Killing files - PhilOfPerth - 06-05-2025 I have a folder called RecallHist containing several files with names like "ABC4, ABC6, POP1, POP6, AB1, BD3 and I need to delete those that start with POP (for example). I've written this code, but the selection$ string is not correct - file is not found. Code: (Select All) Name$ = "POP" How do I place a Wildcard in the string? RE: Killing files - ahenry3068 - 06-05-2025 (06-05-2025, 04:16 AM)PhilOfPerth Wrote: I have a folder called RecallHist containing several files with names like "ABC4, ABC6, POP1, POP6, AB1, BD3I use this $IF WINDOWS THEN KILLCMD$ = "DEL " $ELSE KILLCMD$ = "rm " $END IF Name$ = "POP*" SHELL _HIDE KILLCMD$ + Name$ I don't believe Wild cards work with the Internal Kill command RE: Killing files - SMcNeill - 06-05-2025 A question mark is a wildcard for one character. A star is a wildcard for any number of characters. DIR a? would work with: a0 a1 a2 But not: a01 a02 a03 DIR a* would work with any file that begins with a(anything after). The * symbol is probably the one you're wanting to use here. RE: Killing files - bplus - 06-05-2025 or more QBistically and less DOS like: If Ucase$(Left$(filename$, 3)) = "POP" Then Kill filename$ RE: Killing files - RhoSigma - 06-05-2025 Jesus Christ boys, where do you live? KILL "path/POP*" and be done with it. RE: Killing files - OldMoses - 06-05-2025 (06-05-2025, 09:30 AM)RhoSigma Wrote: Jesus Christ boys, where do you live?This one gets my vote, one's path to pop stardom is easily killed... ![]() RE: Killing files - ahenry3068 - 06-05-2025 One reason I use the SHELL method with the Operating system command is that I can also use it to nuke whole directory trees with one Command WHERE Necessary. I do believe I was incorrect about the built in KILL command not taking wildcards though. RE: Killing files - PhilOfPerth - 06-05-2025 (06-05-2025, 09:30 AM)RhoSigma Wrote: Jesus Christ boys, where do you live? The problem with both of these is that the character after POP varies for each file. Kill "path/POP* doesn't accept the * - it doesn't like the * and returns File Not Found. (06-05-2025, 08:43 AM)bplus Wrote: or more QBistically and less DOS like: Sorry bplus, I missed your suggestion. I'll give that a go now. Thanks RE: Killing files - Kernelpanic - 06-05-2025 It's even easier, folks! ![]() ![]() RE: Killing files - RhoSigma - 06-05-2025 Phil, I hope you did replace "path" in my example with your actual folder specification eg. KILL "C:\Phil\RecallHist\POP*" or KILL "C:\Phil\RecallHist\POP*.txt" to delete only text files starting with POP |