Jump to content
UBot Underground

Delete The Old Files On Desktop By Extension


Recommended Posts

Okay so I have my script moving the 2 CSV files from the Download folder to Desktop. After I run my Batch command it merges the 2 files. Where I'm stuck is I need to delete the %OriginalFiles  now living on the Desktop but leave the new CSV alone.

 

Here is the part of my code that works.

 

Cheers Jason

 

clear list(%OriginalFiles)
wait(2)
set(#DownloadFolder,$replace($special folder("Desktop"),"Desktop","Downloads"),"Global")
wait(2)
add list to list(%OriginalFiles,$get files(#DownloadFolder,"Yes"),"Delete","Global")
wait(2)
set list position(%OriginalFiles,1)
wait(2)
loop(2) {
    move file($next list item(%OriginalFiles),$special folder("Desktop"))
}
wait(2)
shell("cmd /c \"{$special folder("Desktop")}\\csv maker\\makecsvnodup.bat\"")

Link to post
Share on other sites

try

clear list(%OriginalFiles)
set(#DownloadFolder,$replace($special folder("Desktop"),"Desktop","Downloads"),"Global")
add list to list(%OriginalFiles,$get files(#DownloadFolder,"Yes"),"Delete","Global")
set list position(%OriginalFiles,0)
loop($list total(%OriginalFiles)) {
    set(#File,$next list item(%OriginalFiles),"Global")
    if($ends with($change text casing(#File,"Lower Case"),".csv")) {
        then {
            move file(#File,$special folder("Desktop"))
        }
        else {
        }
    }
}
shell("cmd /c \"{$special folder("Desktop")}\\csv maker\\makecsvnodup.bat\"")
Link to post
Share on other sites

V2

clear list(%OriginalFiles)
set(#DownloadFolder,$replace($special folder("Desktop"),"Desktop","Downloads"),"Global")
add list to list(%OriginalFiles,$get files(#DownloadFolder,"Yes"),"Delete","Global")
set list position(%OriginalFiles,0)
loop($list total(%OriginalFiles)) {
    set(#File,$next list item(%OriginalFiles),"Global")
    if($ends with($change text casing(#File,"Lower Case"),".csv")) {
        then {
            set(#DesktopFile,$replace(#File,#DownloadFolder,$special folder("Desktop")),"Global")
            if($file exists(#DesktopFile)) {
                then {
                    delete file(#DesktopFile)
                }
            }
            move file(#File,$special folder("Desktop"))
        }
        else {
        }
    }
}
Link to post
Share on other sites

Never mind I couldn't sleep lol! I tried both of the versions. None of them are moving the files to the desktop like my original script did. The files have upper and lowercase characters and numbers for the file names. 

 

Example: 8c4bS020160830211541.csv

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...