Sign in to follow this  
Followers 0
jax157

Need to locate and delete file extension, and them move file

15 posts in this topic

I need to be able to locate a file in ANY folder that has a certain file extension, and then delete that extension, and then move the file to a certain network location. What is the script to do that? Thanks in advance for your help! :)

Share this post


Link to post
Share on other sites



Also, is it possible to drag and drop the .au3 file into the folder I need, and have it automatically run the script, and then delete itself from that folder? Hope that makes sense....

Share this post


Link to post
Share on other sites

Please show your code so we can help you ;)

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites

Please show your code so we can help you ;)

Hi!

I do not have any code....hoping for that here. This is a muti-times per day task that I am looking to speed up.

Share this post


Link to post
Share on other sites

If you are trying to do something in one directory then something in another directory without leaving code in the previous one, then you might want to look at FileChangeDir in the help file.

If we knew exactly what the final goal you are trying to accomplish, it would help us understand. You will get more help if you are more descriptive.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

I do not have any code....hoping for that here. This is a muti-times per day task that I am looking to speed up.

Sorry but we don't write code on commission. Maybe take a look on Rent a Coder

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites

Search for RecFileListToArray in the examples section. May I also suggest reading the help file that comes with AutoIt. Good luck.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

jax157,

As you have probably noticed by now, no-one here is too keen to help the "code it for me" brigade. We work more on the "Give a man a fish, you feed him for a day; give a man a net and you feed him forever" principle - basically we try to be net makers and repairers, not fishmongers. ;)

What you want to do is very simple. Look at the RecFileListToArray UDF in my sig - that will find the file for you. FileMove will then let you rename and move the file in one go. As to the request in your second post, I am afraid that I do not really understand what you want to do - you can run an AutoIt script from any location and use a choice dialog to set the folder in which you want to start the search. So I do not see why you would want to "drag'n'drop" and then delete the script - it would make more sense to keep it, particularly as you say this procedure is required several times a day. :)

Take a look at the UDF and the function I mentioned and see what you can come up with - we are very ready to help if you make some effort yourself first. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

OK....I am understanding how this works. To give some background...I have never "coded" anything before. (unless you count a macro in m-word that did a simple find-and-replace, and I copied and pasted that code from an online post....cheating, I know) However, I am not afraid to wade into the weeds and give things a try. I will be looking into everyone's ideas and examples and will be posting the results.

As to the details and specifics of what I am trying to accomplish:

I am operating CNC machining centers. When I create a CNC program (nothing more than lines of text), I use CAM software that allows me to create toolpaths based on 3D CAD data (3D Models), and then the CAM software post-processes the toolpaths into a code format (G-Code) that the CNC machine control can read and execute.

When the post-processing happens, the CAM software creates the code file with a proprietary file extension. BUT, the machine control can't read that extension, so I have to delete it, leaving it with NO extension. This is the first task I want the autoit script to do.

Next, I must send the file to the hard drive on the machine control. The machine control is connected via CAT-5 to our shop network, and therefore is a network place. And so I right-click the file, select SEND TO, and then click on the machine control on the list, and off it goes out to the machine for execution. This copying of the file from the job folder where it was saved out to the machine control is the second task I want the script to accomplish.

Third, the files aren't necessarily in the same location every time. Each different job we are working on has it's own job folder, so I wanted the ability for the code to be dragged into any folder, find the file, remove the extension, send it to the machine control, and then move itself from that folder to a common location....say my desktop.

I hope I make sense to you, and that this clarifies my goals. it sounds like some of the script examples above address these tasks, and I will be trying them out.

Thanks again for your help and patience. Looking forward to flinging out the "net" :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

jax157,

I coded something very similar for a high-speed carpentry router a few years ago, so what you want is eminently doable with AutoIt. :thumbsup:

As I suggested above, I see no reason to drag the code to the relevant folder - you can use the FileSelectFolder dialog to set a base folder for the search and keep the script in a central location. ;)

I have changed your status so that you can use the PM system. As the work I did before was proprietary I cannot post it on the open forum, but we might be able to come to an arrangement for some private "net-flinging" classes - standby for incoming. ;)

M23

Edit: PM sent.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ok, did some testing and here's what I got so far:

; Script Start - Add your code below here

; Shows the filenames of all files in the current directory.

Local $search = FileFindFirstFile("*.tap*")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

Local $file = FileFindNextFile($search)

If @error Then ExitLoop

MsgBox(4096, "File:", $file)

WEnd

; Close the search handle

FileCopy("C:UsersComputer UserDocuments*O9500.tap*" , "ftp://1XI@192.168.1.253/")

As you can see, I wanted to locate any file that has the .tap extension...did that. :thumbsup:

Next, I wanted to copy that file from it's location to a different location on my C drive....did that no problem. (the code is identical as above except there is a different target location) :thumbsup:

Next, I wanted to copy that file to a network location, which you see the code for above....did NOT do that :(

What am I doing wrong?

Thanks in advance for your help!

-J157

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Take a look to _FTP_Connect and its related function expecially _FTP_FilePut.

Hi!

Edited by Nessie

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites

Ok, I've been trying the FTP commands, but not sure what goes first..._FTP_Connect...._FTP_Open....._FTP_Fileput?

What is the correct order?

Thank you!

Share this post


Link to post
Share on other sites

An express example:

#include <FTPEx.au3>

$host = 'host'
$username = 'Username'
$pass = 'Password'

$open = _FTP_Open('FTP Uploader')
$connect = _FTP_Connect($open, $host, $username, $pass)
_FTP_FilePut($connect,@DesktopDir & "\test.txt","/test.txt")
$close = _FTP_Close($open)

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

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