Sanjeev 46 Posted July 22, 2013 Report Share Posted July 22, 2013 Fellas? I need to get the size of a file (In bytes - MB/Kb ) inside a specific folder.. I realize it can currently only be done via shell commands.I would be grateful for any help . Thanks. Quote Link to post Share on other sites
k1lv9h 76 Posted July 23, 2013 Report Share Posted July 23, 2013 Hi, Sample code: set(#file, "c:\\downloads\\dirlist.txt", "Global") set(#filename, $replace regular expression(#file, ".*\\\\", $nothing), "Global") shell("cmd.exe /C dir /-C {#file} | find \"{#filename}\"> c:\\downloads\\file-size.txt") clear list(%dirresult) add list to list(%dirresult, $list from text($read file("c:\\downloads\\file-size.txt"), " "), "Delete", "Global") set(#filesize, 0, "Global") if($comparison($list total(%dirresult), ">", 2)) { then { set(#filesize, $list item(%dirresult, 3), "Global") } else { } } sample-dir-file-size-001.ubot Kevin 1 Quote Link to post Share on other sites
Sanjeev 46 Posted July 23, 2013 Author Report Share Posted July 23, 2013 Kevin? You're a Command Line genius!! Thanks a lot man! Couple Of questions if you don't mind? 1. where can I start to learn about command line scripting..? any good resources please?2. why do you do - if list total is > 2 then set #filesize to list item 3? Why not just set #filesize to list item 3? Thanks a lot Buddy! Quote Link to post Share on other sites
k1lv9h 76 Posted July 23, 2013 Report Share Posted July 23, 2013 Hi, 1. where can I start to learn about command line scripting..? any good resources please?I use this site for what commands are available and syntax: http://ss64.com/nt/ I also will use Windows command with /? to provide syntaxI then use search(google/bing) to find code samples. 2. why do you do - if list total is > 2 then set #filesize to list item 3? Why not just set #filesize to list item 3?I put the check in just in case the file goes missing while getting file size. Keeps ubot from getting script error on set #filesize to list item 3 when there are 2 or less items in list. Kevin Quote Link to post Share on other sites
UBotDev 276 Posted July 24, 2013 Report Share Posted July 24, 2013 You could also use "shell function" from my free Advanced Shell plugin, which doesn't need txt file to be saved, instead content if written to UBot variable directly. Besides that it will also run cmd window hidden. You can find more info here:http://ubotdev.com/free-plugin-advanced-shell#function-shellcommand-prompt-batch-hidden Quote Link to post Share on other sites
Sanjeev 46 Posted July 24, 2013 Author Report Share Posted July 24, 2013 Wow! Great solutions from Cool Ubotters! Thanks! Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 24, 2013 Report Share Posted July 24, 2013 returned file size with PHP Compilerhttp://screencast.com/t/pWpV5vmqNT Quote Link to post Share on other sites
Sanjeev 46 Posted July 24, 2013 Author Report Share Posted July 24, 2013 Thanks TJ. Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 24, 2013 Report Share Posted July 24, 2013 no problem. Quote Link to post Share on other sites
nicolai 4 Posted May 7, 2017 Report Share Posted May 7, 2017 Hi everybody.Why is this so complicated? Surely there is an easier way to get the size in bytes of a downloaded file?Is it not built into ubot studio already? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 8, 2017 Report Share Posted May 8, 2017 Hi everybody. Why is this so complicated? Surely there is an easier way to get the size in bytes of a downloaded file? Is it not built into ubot studio already? It is not built into Ubot, there are a couple of plugins that do it though, this one is free: TJ's system commands: http://network.ubotstudio.com/forum/index.php/topic/20737-21-free-plugins-being-given-away/ Quote Link to post Share on other sites
nicolai 4 Posted May 8, 2017 Report Share Posted May 8, 2017 It is not built into Ubot, there are a couple of plugins that do it though, this one is free: TJ's system commands: http://network.ubotstudio.com/forum/index.php/topic/20737-21-free-plugins-being-given-away/In the end I used FileFolderCommand plugin to get file size. This function gets the file size of the downloaded file and then, displays the file size in the html + also increases the total data downloaded and also converts the bytes to two decimal MB number. Took me around 6 hours to get it working correctly! define get_file_size(#file_path) { set(#this_file_size,$plugin function("FileFolderCommands.dll", "$get file info", #file_path, "Total Size"),"Global") set(#total_data_downloaded_bytes,$add(#total_data_downloaded_bytes,#this_file_size),"Global") set(#this_file_size_downloaded_mb,$number format($divide(#this_file_size,1048576)),"Global") set(#total_data_downloaded_mb,$number format($divide(#total_data_downloaded_bytes,1048576)),"Global") } Thank you everyone for helping me. 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.