Home | Blog | Software |

Did you miss your activation email?

• August 31, 2015, 08:55:41 PM
• Proudly celebrating 10 years online.
• Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.

Author Topic: A software for compress file and able to find them first  (Read 2892 times)

Contro

• Participant
• Joined in 2007
• Posts: 2,453
A software for compress file and able to find them first
« 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.

• Supporting Member
• Joined in 2009
• Posts: 6,195
Re: A software for compress file and able to find them first
« 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.sour...ge.net/packages.html

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« Reply #2 on: July 31, 2012, 06:34:55 PM »
going

Best Regards

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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

eleman

• Spam Killer
• Supporting Member
• Joined in 2009
• Posts: 340
Re: A software for compress file and able to find them first
« 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.
Code: [Select]
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.

• Supporting Member
• Joined in 2008
• Posts: 822
Re: A software for compress file and able to find them first
« 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. )
If bad things happen to other people, it's karma. If bad things happen to me, it's kismat!
« Last Edit: August 01, 2012, 06:34:08 AM by daddydave »

• Supporting Member
• Joined in 2008
• Posts: 822
Re: A software for compress file and able to find them first
« 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.
Code: [Select]
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

Code: Text
1. @echo off
2. setlocal
3. set oldcd=%cd%
4. for /R %%D in (.) do (
5.  cd "%%D"
6.  %*
7. )
8. cd /d %oldcd%
9. endlocal
10.

Maybe it would be of some use.

Edit: corrected a bug I just now saw, lol
If bad things happen to other people, it's karma. If bad things happen to me, it's kismat!

• Supporting Member
• Joined in 2008
• Posts: 822
Re: A software for compress file and able to find them first
« 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?
If bad things happen to other people, it's karma. If bad things happen to me, it's kismat!

eleman

• Spam Killer
• Supporting Member
• Joined in 2009
• Posts: 340
Re: A software for compress file and able to find them first
« 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:

Code: [Select]
setlocalset 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.

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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:

Code: [Select]
setlocalset 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.

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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.

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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.

skwire

• Global Moderator
• Joined in 2005
• Posts: 4,391
Re: A software for compress file and able to find them first
« 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

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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 ?

• Supporting Member
• Joined in 2009
• Posts: 6,195
Re: A software for compress file and able to find them first
« 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

Code: [Select]
; run with filename on command line; whatever the starting directory of the filename, it will recursively dig into all folders beneath;if 0 < 1{  InputBox,FilePat,,Enter File Name (e.g. C:\readme.txt)  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 »

Contro

• Participant
• Joined in 2007
• Posts: 2,453
Re: A software for compress file and able to find them first
« 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

• Supporting Member
• Joined in 2009
• Posts: 6,195
Re: A software for compress file and able to find them first
« 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 »