Jump to content
Sign in to follow this  
ezzetabi

Empty filename renamer

Recommended Posts

Works better with extension less files (or files that have the extension hidden like .lnk).

Local $text = FileOpenDialog('Select the file(s)', @HomeDrive, 'All (*)', 5)
If @error Then Exit

If StringInStr($text, '|') Then
   Local $files
   $files = StringSplit($text, '|')
   If StringRight($files[1], 1) <> '\' Then $files[1] = $files[1] & '\'
Else
   Local $files[3]
   $files[0] = 2
   $files[1] = StringLeft($text, StringInStr($text, '\', 0, -1))
   $files[2] = StringTrimLeft($text, StringInStr($text, '\', 0, -1))
EndIf

Local $filen, $c, $ext
$filen = " " ;<--- if it does not work replace the 'space' with a ALT+255

For $c = 2 to $files[0]
   While FileExists($files[1] & $filen & '.*')
      $filen = $filen & " " ;<--- if it does not work replace the 'space' with a ALT+255
   Wend

   $ext = StringTrimleft($files[$c], StringInStr($files[$c], '.', 0, -1)-1)
   FileMove($files[1] & $files[$c], $files[1] & $filen & $ext)
Next

Share this post


Link to post
Share on other sites

Thats pretty cool :)


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

Improved, no need to add a ALT+255 if extension is different...

Local $text = FileOpenDialog('Select the file(s)', @HomeDrive, 'All (*)', 5)
If @error Then Exit

If StringInStr($text, '|') Then
   Local $files
   $files = StringSplit($text, '|')
   If StringRight($files[1], 1) <> '\' Then $files[1] = $files[1] & '\'
Else
   Local $files[3]
   $files[0] = 2
   $files[1] = StringLeft($text, StringInStr($text, '\', 0, -1))
   $files[2] = StringTrimLeft($text, StringInStr($text, '\', 0, -1))
EndIf

Local $filen, $c, $ext
$filen = " "

For $c = 2 to $files[0]
   $ext = StringTrimleft($files[$c], StringInStr($files[$c], '.', 0, -1)-1)
   While FileExists($files[1] & $filen & $ext)
      $filen = $filen & " "
   Wend

   FileMove($files[1] & $files[$c], $files[1] & $filen & $ext)
Next

Share this post


Link to post
Share on other sites

I ran it on a text file, and the filename just became a space (I checked, ASCII code 40)...Is that what is supposed to happen? Alt+1060 works even better if you want to hide a file from someone, as it is a non-breaking-space, something not available on a keyboard.


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

ASCII 40(decimal) is a '('

ASCII 40(hex) is a '@'

About ALT-1060 it is not a space.

What are saying?

Anyway it is a 'emtpy filename renamer', it just change the name with a empty name using the 255th char of OEM ASCII table.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

MSLx Fanboy meant ALT+0160.

I don't mean to talk bad about your script, but it's pointless. Automation is supposed to make complex tasks simple. This script does the opposite.


DreamHost: great web hosting for as little as $7.95 a month.

Share this post


Link to post
Share on other sites

Hehe, see, that's why I have to keep asking you GL. I'm a tiny bit dyslexic with ASCII codes...


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

Local $text = FileOpenDialog('Select the file(s)', @HomeDrive, 'All (*)', 5)
If @error Then Exit

If StringInStr($text, '|') Then
   Local $files
   $files = StringSplit($text, '|')
   If StringRight($files[1], 1) <> '\' Then $files[1] = $files[1] & '\'
Else
   Local $files[3]
   $files[0] = 2
   $files[1] = StringLeft($text, StringInStr($text, '\', 0, -1))
   $files[2] = StringTrimLeft($text, StringInStr($text, '\', 0, -1))
EndIf

Local $filen, $c, $ext
$filen = Chr ( 0 )

For $c = 2 to $files[0]
   $ext = StringTrimleft($files[$c], StringInStr($files[$c], '.', 0, -1)-1)
   While FileExists($files[1] & $filen & $ext)
      $filen = $filen & " "
   Wend

   FileMove($files[1] & $files[$c], $files[1] & $filen & $ext)
Next

thats better, on a shortcut there is no box below the icon when you select it.


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

MSLx Fanboy meant ALT+0160.

I don't mean to talk bad about your script, but it's pointless. Automation is supposed to make complex tasks simple. This script does the opposite.

<{POST_SNAPBACK}>

of course autoit is for automation.. but its fine to have fun with it, and make coolio scripts like ezzetabi just did :)

FootbaG

Share this post


Link to post
Share on other sites

And seeing as you can't do this manually, I don't think anyway, I think its a good script as to broaden the horizon of our physical boundaries.


qq

Share this post


Link to post
Share on other sites

And seeing as you can't do this manually, I don't think anyway, I think its a good script as to broaden the horizon of our physical boundaries.

The reason I made the statement above is because you CAN do this manually. It is accually simpler than using his script.

1. Create a folder

2. Rename folder by holding down ALT and pressing 0160 on your keypad

That's it.

Also, as was said earlier, you can create a link with no name - just the .lnk extention.


DreamHost: great web hosting for as little as $7.95 a month.

Share this post


Link to post
Share on other sites

@Green Lantern

Yep, but for a file you have actually to:

1. select the file

2. press F2

3. press Left arrow 4 or more times

4. press shift + home

5. press ALT+255 (or ALT+0160)

I never said this script was a ultimate geniality.

It is just a little joke. If you do not like it, avoid this topic.

@Xenogis

It does not work to me! Are you sure you can add Chr(0) to autoit's strings?

@MSLx Fanboy

I was wrong, sorry. You probably meant 40 in octal that is actually a space. But please explicit what base you use. Ok?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...