Jump to content

File Splitter


CoderDunn
 Share

Recommended Posts

File Splitter 1.1

I made this script to split large files so I could send them in email attachments. I know you can do this with a compressed archive like RAR but that takes away the fun of making your own :whistle: The script is dependent on file names so dont rename files after splitting. All split files must be in the same directory to rejoin them together.

Hallman

3/21/07 - Version 1.1

- Changed GUI to smashly's version since I liked it better, also smashly's file path selecter is better (more user friendly) and allows the user to select where to save the file(s)

- Added Progress bars

File_Splitter_1.1.au3

Edited by Hallman
Link to comment
Share on other sites

Nice work Hallman,

Does as advertised on the box so to say... Awesome :whistle:

Suggestions for future improvement:

When splitting ask where the user wants to save the split to.

or

Add an option to set the save path of the split.

Add cmdline support so a user can send their file to file splitter or drop their file on the script/exe/shortcut and it opens file split with file path filled in ready to split or join depending on the file extension passed.

Drop & drag support for dropping a file in the gui, depending on the file extension will determine to split or join

Some kind of progress indicator.

I thoroughly like your excellent script ...

All Good

Thank You

&

Cheers.

Link to comment
Share on other sites

Nice work Hallman,

Does as advertised on the box so to say... Awesome :whistle:

Suggestions for future improvement:

When splitting ask where the user wants to save the split to.

or

Add an option to set the save path of the split.

Add cmdline support so a user can send their file to file splitter or drop their file on the script/exe/shortcut and it opens file split with file path filled in ready to split or join depending on the file extension passed.

Drop & drag support for dropping a file in the gui, depending on the file extension will determine to split or join

Some kind of progress indicator.

I thoroughly like your excellent script ...

All Good

Thank You

&

Cheers.

Thanks. I have thought about most of those but since this origionally was for personal use, I didn't want to spend the time making it to complicated. I think I will update it then if there is some interest in this.

Edited by Hallman
Link to comment
Share on other sites

Hope you don't mind , but I was bored with my own scipts so I modded your gui a little to add drop files and save paths support.

(hope I didn't break anything.)

[...]

Cool, makes my job easier since Iv'e been busy with school lately and havn't had much time to mess around with it (Only did a progress bar for file splitting).

What I did:

You might want to import the progress bar from mine since it has a progress bar for both the current file and the total % done.

File_Splitter_1.0.au3

One more thing ... in your script the user can change the byte type (MB,KB,bytes) split but you havn't made the script able to calculate anything other than mega bytes. Also, bytes probably isn't needed since there is 1024 bytes in a single kilobyte! And even dial up goes 5 kilobytes a second (5120 bytes). Thats the reason I only chose MB because I figure your not going to be splitting many files into pieces smaller than one MB (Unless you still use something smaller than a floppy disc xD)

Thanks for the help, Hallman

Edited by Hallman
Link to comment
Share on other sites

Glad you didn't mind...

Yep I like your progress bar :P

I had no idea how to get a reading with the progress bar as I've never used one in any of my scripts yet..lol

Was kinda hoping the cancel button on the progress window would abort the split..

The only way I could work out to abort a split/join once started was to run the split/join functions as another script from the gui. (Send the functions into a temp file and run them via autoit cmd)

This way I can use the pid from run of the join/split function to kill process and keep the gui active , but I thought that to be an ugly way of having an abort not to mention cleaning up the partial slplit/join files. The abort does work if I do it this way though.

Yep the MB/KB/B was just a dummy control, I've since updated my post above and it's now a working control.

I was almost tempted to do a dropdown combo box with common split sizes for quick picking as well.

The reason I wanted kb & bytes was cause I was actually using your code to split sections of a 1mb bios file.. not every one would do this type of thing and I usually use DSplit (free 10KB cmdline splitter) , but since your code works in point of a MB and it's customisable then I thought why not use it for all my basic splitting needs :whistle:

Cheers

Edited by smashly
Link to comment
Share on other sites

Glad you didn't mind...

[...]

Yes thats right u did say it was a dummy control ... I need to start reading the whole post xD I forgot to add the function for the cancel btn (oops). I was just going to put a GuiGetMsg() in the loop where it writes the file data. Having it in a separate script is kinda messy. There might be a better way of doing it. Warning: Trying to split a file into pieces less than 4095 bytes (4 KB) WILL NOT WORK since the script reads 4095 bytes every loop. I can change this of course if it's needed. I have a new idea for this script ... will be working on it.

Hallman

Edited by Hallman
Link to comment
Share on other sites

Warning: Trying to split a file into pieces less than 4095 bytes (4 KB) WILL NOT WORK since the script reads 4095 bytes every loop.

Yep and no ,

No you can't write a 1 byte file to a hd as file using 1 byte of harddrive space, as it will be 4096 bytes with only 1 byte of data from the original file.

This would be the case even if you didn't have 4095 loop. (this more depends what you have your allocation sizes set to for your harddrive)

But bytes will split in byte accuracy even if your code is left as 4095 loops

eg:

Use a small 1kb text file to split into bytes. set the byte size to 1 and split

Yep now you have mutiple files of 1kb , but each file only contains 1 byte of data even though each split file take up 1kb of harddrive space. In other words if your unsplit text file had 72 characters in it, then after split you would have 72 x 1kb files containing 1 character in each file, each character = 1 byte. :P

same again:

Open notepad , write 2 characters (eg: ab) then save , properties of your new text will be

Size: 2 bytes (2 bytes)

Size on Disk: 4.00 KB (4,096 bytes) <-- (this is depending on allocation sizes set to for your harddrive)

Now split the new text file into bytes. Set the byte size to 1 and split..

You now have 2 x 1KB files that each contain 1 character (1 byte)

My examples are pointless , but your 4095 loop will write 1 byte of data.

If you try to split 1 byte file then your going to get your msgbox saying that "The Size you imputed is larger then the file itself"

I have a new idea for this script ... will be working on it.

Looking forward to it ... w00t :whistle:

Cheers.

Edited by smashly
Link to comment
Share on other sites

Yep and no ,

No you can't write a 1 byte file to a hd as file using 1 byte of harddrive space, as it will be 4096 bytes with only 1 byte of data from the original file.

This would be the case even if you didn't have 4095 loop. (this more depends what you have your allocation sizes set to for your harddrive)

But bytes will split in byte accuracy even if your code is left as 4095 loops ...

Alright. I added my progress bars to your modded version (I like the GUI better), changed split and join functions a bit ... now version 1.1 (see first post). Still working on my idea ...

Hallman

Edited by Hallman
Link to comment
Share on other sites

Thank You & Nice work hallman.

Ooops something is broken, I no longer get the split or join option when I drop a file into the input file field.

But it does work when I use the browse button :P

I do like the progress window, damnnn nice! :D

When I split a file the gui hides hides while the progress window shows , I like this .. all good

When I join a file the gui stays visable while the progress window shows.. can you do the same as split for this.

Now to actually look at your modded code :whistle:

I only run the code and haven't actually looked at the changes yet ... tsk tsk on me..lol

Cheers.

Edited by smashly
Link to comment
Share on other sites

Ooops something is broken, I no longer get the split or join option when I drop a file into the input file field.

Must of done something ... maybe u can figure it out as I didn't write that part of it ... help is apreciated

When I join a file the gui stays visable while the progress window shows.. can you do the same as split for this.

oops forgot to do this ... EDIT: fixed it see first post

The modified code was mostly just to make the join function more progress friendly and I changed the read 4095 bytes every loop to 20000 so it runs a little faster.

Hallman

Edited by Hallman
Link to comment
Share on other sites

Done some 1.1 fixes..

Fixed drop files

Added show n hide gui for progress when joining (doh I was to slow, just saw your edited post above..lol)

Resized/moved progress window so it shows up where the gui was.

Updated in my post under your 2nd post.

Yep split is definately faster now .. nice job m8 :whistle:

Cheers

Edited by smashly
Link to comment
Share on other sites

Done some 1.1 fixes..

Fixed drop files

Added show n hide gui for progress when joining (doh I was to slow, just saw your edited post above..lol)

Resized/moved progress window so it shows up where the gui was.

Updated in my post under your 2nd post.

Yep split is definately faster now .. nice job m8 :whistle:

Cheers

ok thanks. Updated first post.

Hallman

Edited by Hallman
Link to comment
Share on other sites

Doh..

Sorry , I changed my post above again since ...

Trivial: Changed the gui & group size since the progress bar is no longer on the gui.

Cheers

Edit: Once again another trivial change ...

Added "Split file progress..." and "Join file progress..." to progress window title, depending if splitting or joining :whistle:

Edited by smashly
Link to comment
Share on other sites

Doh..

Sorry , I changed my post above again since ...

Trivial: Changed the gui & group size since the progress bar is no longer on the gui.

Cheers

np. Updated first post (fixed a few typos and fixed a small bug with the join function on top of what you did)

Edited by Hallman
Link to comment
Share on other sites

Well loop amount @ 20000 bytes works well if your splitting files over 20000 bytes , but it does break splitting if the file is under 20000 bytes..

I'm thinking of writing a condition for the loop amount so it'll work correctly again with files under 20000 bytes.

For now I will keep the 4095 loop as it works with all as long as the hd it's reading/writing to is in 4KB allocation size.

Cheers.

Edit: hmm, something changed in one of the updates , I can still no longer split bytes even with 4095 set as a loop...

Edit: Found the problem ... it's the $Loop_Amount variable, it's not been declared outside the loop it's in.

has nothing to do with 20000 bytes.

Edited by smashly
Link to comment
Share on other sites

Well loop amount @ 20000 bytes works well if your splitting files over 20000 bytes , but it does break splitting if the file is under 20000 bytes..

I'm thinking of writing a condition for the loop amount so it'll work correctly again with files under 20000 bytes.

For now I will keep the 4095 loop as it works with all as long as the hd it's reading/writing to is in 4KB allocation size.

Cheers.

It shouldn't break it ... I anticipated this so thats what line 313 is for (If $Split_Size >= 20000 Then) If the split size is less, it goes to the Else (FileWrite($Open_Cur_File, FileRead($Open_File, $Split_Size))). It should work fine. (Make sure you download the latest upload where I fixed a small related bug)

EDIT: I just tested it ... works ...

Edited by Hallman
Link to comment
Share on other sites

Yep trust me not to be upto date :"> lol

Works as it should as you said :P

You may or may not want to add to split and join functions respectively...

WinSetTitle($Progress_Win, '', 'Split file progress...')oÝ÷ Ù©Ýjëh×6WinSetTitle($Progress_Win, '', 'Join file progress...')

Trivial cosmetic touch... :whistle:

I removed my over done post with the code as it just make the thread hard to read and you've updated all changes anyways.

I would of attached the code , but I have no space left on the board atm , I need to clean up my act and stop chewing the boards bw..

Thank You

'n'

Cheers

Link to comment
Share on other sites

Yep trust me not to be upto date :"> lol

Works as it should as you said :P

You may or may not want to add to split and join functions respectively...

WinSetTitle($Progress_Win, '', 'Split file progress...')oÝ÷ Ù©Ýjëh×6WinSetTitle($Progress_Win, '', 'Join file progress...')

Trivial cosmetic touch... :whistle:

I removed my over done post with the code as it just make the thread hard to read and you've updated all changes anyways.

I would of attached the code , but I have no space left on the board atm , I need to clean up my act and stop chewing the boards bw..

Thank You

'n'

Cheers

no problem. Yeah I think that would be a small but good change. I'll update it in a bit gonna let my bro play on computer right now.

EDIT: done, changed the comments at the top of the script a bit. See first post

Edited by Hallman
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...