Delete files using Wildcard not working
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2010
06:38 AM
06-02-2010
06:38 AM
Delete files using Wildcard not working
Hi,
I am trying to delete file "c:\Bun272010-06-02T141405.PDF" where the portion after the letter 'T' --'141405' in the filename is the file creation time and this keeps changing whenever the file is created so it cannot be hard-coded.
I tried the codes below using wildcard but that none of them works to delete the files..
(fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
I am trying to delete file "c:\Bun272010-06-02T141405.PDF" where the portion after the letter 'T' --'141405' in the filename is the file creation time and this keeps changing whenever the file is created so it cannot be hard-coded.
I tried the codes below using wildcard but that none of them works to delete the files..
if (fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
(fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
if (fs.FileExists('c:\\Bun27' + r2wdate + '*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + '*.pdf');
if (fs.FileExists('c:\\*.pdf')) fs.DeleteFile('c:\\*.pdf');
Thanks,
Sumedha
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2010
03:29 AM
06-03-2010
03:29 AM
Hi Sumedha,
You can use the script below to delete the files:
aqFileSystem.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
aqFileSystem.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
aqFileSystem.DeleteFile('c:\\Bun27' + r2wdate + '*.pdf');
Please refer to the "aqFileSystem.DeleteFile" article to learn more about the aqFileSystem.DeleteFile method.
Best regards,
Alexey
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2010
05:27 AM
06-03-2010
05:27 AM
Hi Allen,
Thanks for the suggestion.I saw that it works without using 'if' statement but with 'if' statement ,does not. Is there some specific reason for that. Can't we use wildcards in 'aqFileSystem.Exists' ?
Thanks,
Sumedha
Thanks for the suggestion.I saw that it works without using 'if' statement but with 'if' statement ,does not. Is there some specific reason for that. Can't we use wildcards in 'aqFileSystem.Exists' ?
Thanks,
Sumedha
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2010
01:53 AM
06-04-2010
01:53 AM
Hi Sumedha,
Wildcards are not supported in the aqFileSystem.Exists method. See the "aqFileSystem.Exists" article for details.
You can use the aqFileSystem.FindFiles method to find the files whose names will meet the specified search pattern (you can use wildcards there) and delete them. Please refer to the "aqFileSystem.FindFiles" article fore more information.
Best regards,
Alexey
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
