Sign in to follow this  
Followers 0
Wollf

search-rename-move file

4 posts in this topic

Hello i want to make something that will search all files with certain ending but different names *.kwreplay at deskpot. then i want to make it take them from bigger to smaller and rename them with numbers 1.kwreplay, 2.kwreplay and at the end move them at a place. what command i need to use and learn for this one?

Share this post


Link to post
Share on other sites



Hello i want to make something that will search all files with certain ending but different names *.kwreplay at deskpot. then i want to make it take them from bigger to smaller and rename them with numbers 1.kwreplay, 2.kwreplay and at the end move them at a place. what command i need to use and learn for this one?

Hi,

Search in helpfile this functions :

FileFindFirstFile()
FileFindNextFile()
FileGetSize()
FileRename()
@DesktopDir

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Hello i want to make something that will search all files with certain ending but different names *.kwreplay at deskpot. then i want to make it take them from bigger to smaller and rename them with numbers 1.kwreplay, 2.kwreplay and at the end move them at a place. what command i need to use and learn for this one?

This is what I would probably do.

Have a global variable $filelist.

Use FileFindFirst and FileFindNext to find all the files which match *.kwreplay.

Every time you find a file, get it's size with FileFindSize, and add the size and the name, in that order, to the variable $filelist and add '|' to separate different files.

You will end up with all the files and the sizes in $filelist.

Make an array of the files $aFiles = stringSplit($filelist,'|')

then sort the array into order using _ArraySort

Now you can go through the array and extract the file names and save them as required.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <array.au3>
$a_array = _File_ListBySize(@DesktopDir, "*.kwreplay")
_ArrayDisplay($a_array)

Func _File_ListBySize($s_directory, $s_mask = "*", $f_greatest_to_least = True)
    $s_directory = StringRegExpReplace($s_directory, "[\\/]+\z", "")
    Local $s_files = ""
    Local $i_pid = Run(@ComSpec & ' /c dir /b /o:-s "' & $s_directory & "\" & $s_mask & '"', _
        "", @SW_HIDE, 6)
    While Not @error
        $s_files &= StdoutRead($i_pid)
    WEnd
    If Not $s_files Then Return SetError(1, 0, 0)
    
    Local $a_split = StringSplit(StringStripCR(StringRegExpReplace($s_files, "[\r\n]+\z", "")), @LF)
    If $f_greatest_to_least Then Return $a_split
    
    Local $a_ret[$a_split[0] + 1] = [$a_split[0]], $i_add
    For $i = $a_split[0] To 1 Step - 1
        $i_add += 1
        $a_ret[$i_add] = $a_split[$i]
    Next
    Return $a_ret
EndFunc

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0