Moving files based on file content
Moderators: Hacker, petermad, Stefan2, white
Moving files based on file content
I have an application that produces XML files for communication with another application. It places all of them in one directory. If I were interfacing with only one other application that would be fine... unfortunately, I need to send some of these XML files to one application and others to a completely different application. The only way to determine which application they need to go to is to evaluate the first few lines of the file and look for specific values. Once I have that value, I want to move the file to one directory or another. Once there, then I can use FTP or other mechanism to send the files on to their destination. Does Total Commander have a feature such as this, or if not, does anyone know of a utility that can do what I've described here? thanks in advance!
Hi Ran,
Should be easily doable using a content plugin that provides the first few lines of each file, eg. making use of [wdx] WinScript Advanced Content Plugin (x86\x64) (new) by someone who has about 15 minutes time (which I currently unfortunately do not).
HTH
Roman
Should be easily doable using a content plugin that provides the first few lines of each file, eg. making use of [wdx] WinScript Advanced Content Plugin (x86\x64) (new) by someone who has about 15 minutes time (which I currently unfortunately do not).
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
It depends on how you can search for the file content (your "specific values").
As Hacker pointed out, either you are able to use TC's file search for file content to search and find either group of files, or use some content plug-in for that.
Once you are able to find files inside TC's search, one straightforward solution is to use the search inside your xml file dir and feed the files to listbox after that, each time with another file content search term.
Personally, if these files are an ongoing matter, I would use file colors:
Use Configuration -> Color -> Define colors by file type
Use "Add" and "Define".
Now use unique search parameters for the first group of files, e.g.
Search for: *.xml
Find text: <your value for the xml file or maybe a RegEx>
Now use a distinct color.
Repeat the above steps for the second group of files with a different color
Now you should be able to see quite easily which files belong to which group.
Note that TC's RegEx search unfortunately can't search across lines, but only single lines.
As Hacker pointed out, either you are able to use TC's file search for file content to search and find either group of files, or use some content plug-in for that.
Once you are able to find files inside TC's search, one straightforward solution is to use the search inside your xml file dir and feed the files to listbox after that, each time with another file content search term.
Personally, if these files are an ongoing matter, I would use file colors:
Use Configuration -> Color -> Define colors by file type
Use "Add" and "Define".
Now use unique search parameters for the first group of files, e.g.
Search for: *.xml
Find text: <your value for the xml file or maybe a RegEx>
Now use a distinct color.
Repeat the above steps for the second group of files with a different color
Now you should be able to see quite easily which files belong to which group.
Note that TC's RegEx search unfortunately can't search across lines, but only single lines.
TC plugins: PCREsearch and RegXtract
I only need to evaluate one line of each file (line eight). The two lines will either be:
<Warehouse>08</Warehouse>
or
<Warehouse>05</Warehouse>
The application produces several hundreds to several thousands of these files per hour. They are produced in batch, so it's not spread evenly across the hour. As many as 10k files can show up in the directory within just a few minutes.
I need to automate this process so that it 'wakes up' every few minutes to see if their are files waiting to be evaluated.
<Warehouse>08</Warehouse>
or
<Warehouse>05</Warehouse>
The application produces several hundreds to several thousands of these files per hour. They are produced in batch, so it's not spread evenly across the hour. As many as 10k files can show up in the directory within just a few minutes.
I need to automate this process so that it 'wakes up' every few minutes to see if their are files waiting to be evaluated.
Well, if these lines don't appear later in the file (or at any other position in the xml tree), you should be able to simply use them as the search term for TC's file content search. But if they do, you will need some plug-in for this, to make sure they are only found at the first position.
If you really have that much files in such a short time frame, using file colors is of course cumbersome.
And concerning the automation of this process: this is a completely different matter. You might be able to use AutoHotkey with a timer to send commands to TC, but grouping files and sending them to a different location is not that much "automatable" with TC. Some other users might have some insights into that or may be able to hint you to a standalone solution.
If you really have that much files in such a short time frame, using file colors is of course cumbersome.
And concerning the automation of this process: this is a completely different matter. You might be able to use AutoHotkey with a timer to send commands to TC, but grouping files and sending them to a different location is not that much "automatable" with TC. Some other users might have some insights into that or may be able to hint you to a standalone solution.
TC plugins: PCREsearch and RegXtract
Ran,
Here is a short AutoHotkey script that checks the source dir every ten seconds for *.*, reads the 8th line, compares it to the given strings and moves accordingly. Fully customizable.
HTH
Roman
Here is a short AutoHotkey script that checks the source dir every ten seconds for *.*, reads the 8th line, compares it to the given strings and moves accordingly. Fully customizable.
Code: Select all
#Persistent
#NoEnv
CheckDir = C:\test
CheckFilePattern = *.*
CheckLineNumber = 8
PossibilitiesCount = 2
Text1 = <Warehouse>08</Warehouse>
Text2 = <Warehouse>05</Warehouse>
MoveToDir1 = C:\Warehouse8Files
MoveToDir2 = C:\Warehouse5Files
FileCheckInterval = 10000 ; ms
SetWorkingDir, %CheckDir%
SetTimer, CheckFiles, %FileCheckInterval%
CheckFiles:
Loop, Files, %CheckFilePattern%
{
FileReadLine, Line, %A_LoopFileName%, %CheckLineNumber%
Loop, %PossibilitiesCount%
IfEqual, Line, % Text%A_Index%
{
FileMove, %A_LoopFileName%, % MoveToDir%A_Index%
Break
}
}
Return
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.