Welcome Guest. November 21, 2014, 01:07:00 PM

Or did you miss your validation email?

Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.

 You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 Free DonationCoder.com Member Kit: Submit Request. Entire Forum This board This topic Members Help Desk Entire Site
Pages: [1]   Go Down
 Reply  |  New Topic  |  Print
 Author Topic: A software for compress file and able to find them first  (Read 2519 times)
Contro
Participant

Posts: 2,177

 « on: July 31, 2012, 02:17:09 PM »

A software for compress file and able to find them first

I try to explain. Excuse my language.
I would to scan my hard disk (or disks) for a file with certain conditions.

By example : locate the file       "abc.txt"

When find the file compress to a rar file.

That all.

But compress seperate each file found in his own folder.

By example :

y:\path1\abc.txt to y:\path1\abc.rar

y:\path1\path2\abc.txt to y:\path1\path2\abc.rar

That all I need

Best Regards

More complete more powerful.

 Logged
Member

Posts: 5,035

 « Reply #1 on: July 31, 2012, 05:36:35 PM »

Take a look at a port of Linux find command.  Once you learn the syntax it's simple to have each result launch a command with the result itself as an argument.

http://gnuwin32.sourceforge.net/packages.html

 Logged

"It's only called research if you didn't find it the first time."
Contro
Participant

Posts: 2,177

 « Reply #2 on: July 31, 2012, 06:34:55 PM »

going

Best Regards

 Logged
Contro
Participant

Posts: 2,177

 « Reply #3 on: August 01, 2012, 06:16:25 AM »

Miles is a little difficult for me. It's a wonderful soft package for the dos console.
Is there a soft more GUI or interactive for dummies ?

Best Regards

 Logged
eleman
Spam Killer
Supporting Member

Posts: 286

 « Reply #4 on: August 01, 2012, 06:18:49 AM »

Copy the command line utility of winrar (rar.exe) into somewhere in the path (i.e. windows folder)

Put this in a batch file (*.cmd or *.bat) and run this in the relevant folder.
[copy or print]
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"

I know this does not scan the whole disk for subfolders, but only the current folder, but you can develop the batch file a bit.

MilesAhead's proposed solution may be easier though.
 Logged
Supporting Member

Posts: 818

 « Reply #5 on: August 01, 2012, 06:27:05 AM »

Just now I did this (I have Locate32 and HAOzip installed, I think any archiver would probably do)

• Brought up Locate32 (I can bring it up using Win-F on my system)
• Did a search for .py (Python) files
• Selected a dozen files from the search results.
• Right clicked on the selected results
• Clicked HaoZip > Add to archive (Note: the Windows Explorer right click menu is replicated in Locate32)
• Clicked Browse and browsed to the Desktop
• Gave the filename Test.zip and hit OK.
• Opened the file Test.zip from the desktop and there were all the files I selected.

Is that something like what you need? (Re-reading the original post, I guess you are needing something more automated. It is a little more GUI, though. )
 « Last Edit: August 01, 2012, 06:34:08 AM by daddydave » Logged
Supporting Member

Posts: 818

 « Reply #6 on: August 01, 2012, 06:46:02 AM »

Copy the command line utility of winrar (rar.exe) into somewhere in the path (i.e. windows folder)

Put this in a batch file (*.cmd or *.bat) and run this in the relevant folder.
[copy or print]
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"

I know this does not scan the whole disk for subfolders, but only the current folder, but you can develop the batch file a bit.

MilesAhead's proposed solution may be easier though.

I have a batch file that can run another batch file in the current directory and all subdirectories. Nothing special but I wanted to recreate something I had from the DOS days because I had a need at the time. I call it sweep.cmd

Formatted for Text with the GeSHI Syntax Highlighter [copy or print]@echo offsetlocalset oldcd=%cd%for /R %%D in (.) do ( cd "%%D" %*)cd /d %oldcd%endlocal

Maybe it would be of some use.

Edit: corrected a bug I just now saw, lol
 Logged
Supporting Member

Posts: 818

 « Reply #7 on: August 01, 2012, 06:54:03 AM »

I would to scan my hard disk (or disks) for a file with certain conditions

What tool do you currently use to search for files on your system, are you using the Windows default or a third party tool such as Locate32 or Everything. If Windows, what version of Windows?

Are the "certain conditions" fairly constant or do you want to full search power of your chosen tool?
 Logged
eleman
Spam Killer
Supporting Member

Posts: 286

 « Reply #8 on: August 01, 2012, 07:07:21 AM »

So, combining the line I provided with the work by daddydave:
Put rar.exe into somewhere accessible such as the windows folder, and then use this as a batch file:

[copy or print]
setlocal
set oldcd=%cd%
for /R %%D in (.) do (
cd "%%D"
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"
)
cd /d %oldcd%
endlocal

Run it in the top folder where you want the compression to happen. Don't run it at your root folder or some system files which should remain txt will be compressed as well. That would be asking for trouble.
 Logged
Contro
Participant

Posts: 2,177

 « Reply #9 on: August 01, 2012, 07:09:40 AM »

I would to scan my hard disk (or disks) for a file with certain conditions

What tool do you currently use to search for files on your system, are you using the Windows default or a third party tool such as Locate32 or Everything. If Windows, what version of Windows?

Are the "certain conditions" fairly constant or do you want to full search power of your chosen tool?

You read my little mind. I revived Locate32 last night.
I have certain problems with locate and use less.
My system is windows xp pro sp3
 Logged
Contro
Participant

Posts: 2,177

 « Reply #10 on: August 01, 2012, 07:11:29 AM »

So, combining the line I provided with the work by daddydave:
Put rar.exe into somewhere accessible such as the windows folder, and then use this as a batch file:

[copy or print]
setlocal
set oldcd=%cd%
for /R %%D in (.) do (
cd "%%D"
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"
)
cd /d %oldcd%
endlocal

Run it in the top folder where you want the compression to happen. Don't run it at your root folder or some system files which should remain txt will be compressed as well. That would be asking for trouble.

Going to study.

It seems that all txt file go compressed.
 Logged
Contro
Participant

Posts: 2,177

 « Reply #11 on: August 01, 2012, 07:15:10 AM »

Just now I did this (I have Locate32 and HAOzip installed, I think any archiver would probably do)

• Brought up Locate32 (I can bring it up using Win-F on my system)
• Did a search for .py (Python) files
• Selected a dozen files from the search results.
• Right clicked on the selected results
• Clicked HaoZip > Add to archive (Note: the Windows Explorer right click menu is replicated in Locate32)
• Clicked Browse and browsed to the Desktop
• Gave the filename Test.zip and hit OK.
• Opened the file Test.zip from the desktop and there were all the files I selected.

Is that something like what you need? (Re-reading the original post, I guess you are needing something more automated. It is a little more GUI, though. )

Not very automated.
And the zip is only one. I would like any file individually packed to the corresponding zip or rar.

 Logged
Contro
Participant

Posts: 2,177

 « Reply #12 on: August 01, 2012, 07:17:15 AM »

ull search power of your chosen tool

better full search power of your chosen tool of course, but any limited solution is good too because  i need to do this task now and manually is very boring.

 Logged
skwire
Global Moderator

Posts: 4,157

Another Coding Snack request? Om nom nom...

 « Reply #13 on: August 01, 2012, 10:07:55 AM »

Do you already have a text listing of the files you want compressed?  As in, something like this:

c:\path\abc.txt
c:\another\path\def.txt
c:\more\stuff\ghi.txt

 Logged

Contro
Participant

Posts: 2,177

 « Reply #14 on: August 01, 2012, 12:02:51 PM »

Do you already have a text listing of the files you want compressed?  As in, something like this:

c:\path\abc.txt
c:\another\path\def.txt
c:\more\stuff\ghi.txt

Skwire sounds me as something I must have. But...

How can I obtain the txt file listing ?

 Logged
Member

Posts: 5,035

 « Reply #15 on: August 01, 2012, 03:28:59 PM »

I don't use WinRar so the command line may have to be fixed. I just gleaned it from eleman's post.

Script should be self-explanatory.  You should enter the path as well as filename or the script will start searching in the working directory.  For example, to search all folders on C: for readme.txt use C:\readme.txt as the command line arg.

edit: if no file specified on command line, Input Box asks for the file name. As noted above, the path in the file name with be the start of the folder search. Otherwise it will start in the folder where the script is.

Not tested as I don't have rar.exe installed

[copy or print]
; run with filename on command line
; whatever the starting directory of the filename, it will recursively dig into all folders beneath
;

if 0 < 1
{
if (ErrorLevel)
ExitApp
}
else
FilePat = %1%

Loop, %FilePat%,,1
{
tmp := _FilePathNoExt(A_LoopFileLongPath) . ".rar"
RunWait,rar m -x*.rar -m5 %tmp% %A_LoopFileLongPath%
}

; --------- path manipulation functions - file doos not need to exist, but passing path="" tends to mess them up ----

_FilePathNoExt(path)
{
return _FileDirWithSlash(path) . _FileBaseName(path)
}

_FileExt(path)
{
SplitPath,path,,,ext
return ext
}

_FileBaseName(path)
{
SplitPath,path,,,,basename
return basename
}

_FileName(path)
{
SplitPath,path,filename
return filename
}

_FileDir(path)
{
SplitPath,path,,fdir
return fdir
}

_FileDirWithSlash(path)
{
return _FileDir(path) . "\"
}
 « Last Edit: August 01, 2012, 09:46:33 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
Contro
Participant

Posts: 2,177

 « Reply #16 on: August 01, 2012, 07:59:49 PM »

I'll try. It seems very similar to the other one give me the error windows.

Going to study

 Logged
Member

Posts: 5,035

 « Reply #17 on: August 01, 2012, 08:02:57 PM »

I'll try. It seems very similar to the other one give me the error windows.

Going to study

I know the recursion works properly since I took it from a program I wrote to copy all files matching pattern in a folder tree to a single destination folder.  If you get an error it's probably the WinRar command line. You may have to fix the switches.

edit: code in previous post added InputBox if no command line filename given. So just double click if you prefer.

 « Last Edit: August 01, 2012, 08:57:41 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."