DonationCoder.com Forum

Main Area and Open Discussion => General Software Discussion => Topic started by: MilesAhead on May 11, 2010, 05:27 PM

Title: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on May 11, 2010, 05:27 PM
sike is a command line .exe that sends files/folders to the recycle bin.

Download:  http://www.favessoft.com/downloads.html

Just copy sike.exe to a folder in your path.
sike creates no files, registry or .ini settings.

sike with no params brings up a usage dialog.

Usage: sike [-f] filename1 filename2 ... [may use wildcards]

If -f is not the first param, a confirmation dialog will display,
otherwise sike will loop through the rest of the params sending
files/folders to the recycle bin.

It should work on any Windows flavor that the latest AutoIt3 works on.

It is free for you to use at your own risk.

(There may be a bunch of these around already but I didn't find one that
worked on Vista64 out of the box.  So I knocked this off in AutoIt3.)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: mouser on May 12, 2010, 09:50 AM
thanks for sharing  :up:
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on May 12, 2010, 01:17 PM
:)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: justice on June 11, 2010, 03:51 AM
excellent idea
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: majoMO on June 11, 2010, 07:02 AM
Hi MilesAhead,

FYI, it doesn't work if the filename has some uncommon characters, like: á - ô - ü

E.g.: "mçfilè.txt"

EDIT: if  use it in a .bat file doesn't work - if I use it in a command prompt no annoyances...
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 01:20 PM
excellent idea

Thank you. :)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 01:40 PM
Hi MilesAhead,

FYI, it doesn't work if the filename has some uncommon characters, like: á - ô - ü

E.g.: "mçfilè.txt"

EDIT: if  use it in a .bat file doesn't work - if I use it in a command prompt no annoyances...

Thanks for reporting that info.  On the special characters I believe that is because AutoIt3 itself is ansi. It doesn't support unicode afaik. The command line parsing is a built in feature where you are presented with an array of the command line args: $CmdLine where the first element is the count and the rest of the elements correspond to an arg.  I don't know if there's any easy way to correct it. I'll see if I can find a fix on AutoIt3 forum.

As for the batch file, what kind of error do you get?
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 02:38 PM
Hmmmm, I don't seem to be having much luck with the unicode.  I found some posts on AutoIt3 forum and it seems there's confusion if the command prompt or run box support unicode or what the issue is. There doesn't seem to be a simple way to accommodate it that I can find at present.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 03:21 PM
If you are willing to try some test apps I can try a few things out.  To be honest though, unicode is new to me.  I've just done stuff for English language and ansi.

I compiled this test app with a unicode directive.  I'd like to see if it actually has any effect.  All it does is pop up a box with the command line arguments displayed.

TestCmdLine one two three

but with args that have unicode characters should test if this approach is feasible.

If run with no args it just pops up a MsgBox with Usage: msg.

The zip just contains the compiled AutoIt3 script(without any UPX compression)

(edit: actually the directive was to use UTF-8.)

Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: majoMO on June 11, 2010, 04:11 PM
As for the batch file, what kind of error do you get?

No error at all. It just doesn't copy to recycle bin only.


Bat file with:TestCmdLine.exe sike.exe "mçfilè.txt":

(http://i50.tinypic.com/1em87a.jpg)

Bat file with:TestCmdLine.exe sike.exe "my.txt":

(http://i48.tinypic.com/ei5ug4.jpg)


If I use a .bat file I need to use this to work well:

@echo off
for /f "tokens=2 delims=:" %%a in ('2^>nul chcp') do set cp=%%a
>nul 2>&1 chcp 1252

sike.exe "mçfilè.txt"
>nul 2>&1 chcp%cp%
exit

If I use only «sike.exe "mçfilè.txt"» it doesn't work.

Hope this help.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: daddydave on June 11, 2010, 04:45 PM
Not sure if this would help, but is the batch file itself saved in Unicode or ANSI?

By the way, AutoIt3 has supported Unicode since version v3.2.4.0 but I too don't have much experience with trying to use it in DOS :-[ the command prompt.  

Nice workaround, majoMO!

Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 05:19 PM
(delete please)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 05:27 PM

As for the batch file, what kind of error do you get?

No error at all. It just doesn't copy to recycle bin only.

  • TestCmdLine

Bat file with:TestCmdLine.exe sike.exe "mçfilè.txt":

(http://i50.tinypic.com/1em87a.jpg)

Bat file with:TestCmdLine.exe sike.exe "my.txt":

(http://i48.tinypic.com/ei5ug4.jpg)

  • All-round

If I use a .bat file I need to use this to work well:

@echo off
for /f "tokens=2 delims=:" %%a in ('2^>nul chcp') do set cp=%%a
>nul 2>&1 chcp 1252

sike.exe "mçfilè.txt"
>nul 2>&1 chcp%cp%
exit

If I use only «sike.exe "mçfilè.txt"» it doesn't work.

Hope this help.

Ok so you are saying you have to use the batch file work-around no matter which program you use in the batch?  If that's the case then it looks like the UTF-8 directive is worthless.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 05:30 PM
Not sure if this would help, but is the batch file itself saved in Unicode or ANSI?

By the way, AutoIt3 has supported Unicode since version v3.2.4.0 but I too don't have much experience with trying to use it in DOS :-[ the command prompt. 

Nice workaround, majoMO!



You're right. I confused this with an issue I had with ahk.  AutoIt3 no longer supports Win9x etc..
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 05:34 PM
What they say on AutoIt3 forum seems to indicate the command prompt and run box don't support unicode.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: majoMO on June 11, 2010, 05:47 PM
Sorry but seems that I don't understand (the boxes that comes out are in screenshots).   ::)

What I do is (in .bat):
TestCmdLine.exe sike.exe "mçfilè.txt"

Output:
-[0]|2
-[1]|sike.exe
-[2]|mþfilÞ.txt

In start > run > cmd :
TestCmdLine.exe sike.exe "mçfilè.txt"

Output:
-[0]|2
-[1]|sike.exe
-[2]|mçfilè.txt

If this isn't what I should to do please give me an example (english isn't my native language....).   :stars:
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 05:52 PM
If daddydave and the guys at AutoIt3 forum are right and the issue is the command prompt, maybe this page will be more helpful:

http://www.dpawson.co.uk/xsl/sect2/Unicode.html

Supposedly it fixes up the command prompt to deal with UTF-8.

edit: I've been looking around for a freeware command shell for Windows with unicode support but so far I haven't found anything.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: majoMO on June 11, 2010, 06:00 PM
It seems that the problem is with OEM encoding (and DOS...).

This info could be useful: http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: daddydave on June 11, 2010, 06:08 PM
If daddydave and the guys at AutoIt3 forum are right

I don't know enough about the subject to have an opinion but it interests me and I'm glad you're digging into it.  I'm thinking this probably impacts the command line mode of my NANY 2011 project (https://www.donationcoder.com/forum/index.php?topic=22731.msg205381) as well.

What if the command is launched from FARR and the command line args go there?
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 06:24 PM
If daddydave and the guys at AutoIt3 forum are right

I don't know enough about the subject to have an opinion but it interests me and I'm glad you're digging into it.  I'm thinking this probably impacts the command line mode of my NANY 2011 project (https://www.donationcoder.com/forum/index.php?topic=22731.msg205381) as well.

What if the command is launched from FARR and the command line args go there?

majoMO's TestCmdLine example seems to work fine from FARR.
edit: well, the filename looks like it should. I just pasted from the page here.
But I get some sort of transparent window that disappears only when I close FARR.
Who knows?

Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 06:29 PM
The funny thing is the whole program is only 20 lines of code.  To get it to work with non English environment will probably end up being 80 screens. :)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: daddydave on June 11, 2010, 06:33 PM
So the reason it gives me no problem in Windows 7 x64 is that I have a U.S. version?

[ You are not allowed to view attachments ]

Screenshot posted for your amusement. Yes, I still use the old COPY CON and Ctrl-Z method sometimes. :)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 06:35 PM
When I follow the instructions on that Unicode page I posted, making a cmd prompt using Lucinda font etc... it works on the command line.  At least with the mçfilè.txt file by itself at any rate.

edit: the prompt seems to be persistent... keeping the code page setting (I assume, since the thing seems to work.. sends the file to the bin) it may be worth just making a prompt for stuff where you will use non English characters.  There must be a freebie someplace where all this is automatic. I can't believe we're the first to run into it.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 06:36 PM
So the reason it gives me no problem in Windows 7 x64 is that I have a U.S. version?
 (see attachment in previous post (https://www.donationcoder.com/forum/index.php?topic=22705.msg208919#msg208919))
Screenshot posted for your amusement. Yes, I still use the old COPY CON and Ctrl-Z method sometimes. :)

See my previous post.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: daddydave on June 11, 2010, 06:38 PM
The cmd /u? I didn't have to do anything special for it to work both on the command line or a batch file. What region is your version of Windows?
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 06:40 PM
The cmd /u? I didn't have to do anything special.

I don't know man. I just followed the instructions on the page and it seems to work. I didn't try all the permutations.  I'm not on a non English system, so I'm probably not the guy to test it.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: daddydave on June 11, 2010, 06:59 PM
If I use just about any text editor to open up the batch file I created in DOS, it thinks it's ANSI and garbles it.
[ You are not allowed to view attachments ]
 So ummm, I guess it is ANSI, so never mind!  :-[







Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 09:21 PM
Trouble is to test something you really need the platform. I don't really have the space to keep a guinea pig machine in the corner.  As it is I have 2 PCs with an old kvma switch with PS/2 mouse, keyboard and CRT monitor.  The paint is worn off the HP wheel mouse where the index finger clicks. I can see inside the thing.  But, hey, it still works. :)

I finally changed the settings in Windows so I can launch without double clicking.  Save a bit of wear and tear on my index finger.

Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 11, 2010, 09:25 PM
If I use just about any text editor to open up the batch file I created in DOS, it thinks it's ANSI and garbles it. (see attachment in previous post (https://www.donationcoder.com/forum/index.php?topic=22705.msg208926#msg208926)) So ummm, I guess it is ANSI, so never mind!  :-[









I still think there has to be a command prompt out there that automatically adjusts for unicode and code page or however it works.  otoh in Linux you can get all kinds of free GUI based console shells for free.  Seems like on Windows if they stick a menu on top of the window frame they want $30 for it.  So a self-adjusting freebie may not be out there.

Somebody that's big into parsing maybe that would be a good coding snack. :)
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: Stoic Joker on June 11, 2010, 10:05 PM
Okay this might sound insane...but I do think it a language issue. (Bear with me)

I've been fighting with some .asp stuff and ran across an article (that I now can't find) that described simular character substitutions issues (as described above) during string compare operations when there was a language cross between A & B. I recognize some of the characters that swapped in majoMO's from the article.

May be check/validate the code-page used, or look into some of the runtime localization APIs.

Just thinking out loud here...I could be way off.
Title: Re: sike 1.0 - send file(s) to recycle bin via command line
Post by: MilesAhead on June 12, 2010, 01:37 AM
My impression at this point is that AutoIt3 does unicode, but cmd.exe does not.  However I can't really go to great lengths to test it. I'm not going to install a different version of Windows, for example.  But if someone with a non English version of Windows wants to mess around and see if we can find out the fix, that's fine.  As it is now I've added a link to the unicode info page I found on the web how to set cmd.exe prompt, to the Readme.

I have a shortcut on my desktop that I set up following those instructions but I don't think it will tell me anything since I'm on an English version of Windows anyway.  Someone else needs to run the trials.

edit: The basic theme of my site since it went all donationware is it's software I wrote for my own use, that others may use at their own risk. (I think in all or most of the Readme files I have a note to that effect.)  Obviously I don't have a testing department.  If there's a bug or some other issue I think I can fix with a reasonable effort then I'll try to find a work-around or solution. But there's no promise of support.