Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
June 18, 2013, 10:51:50 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Have VolumeSelect's Name() extract volume from path  (Read 964 times)
jthill
Newbie
*
Posts: 2


View Profile
« on: October 13, 2010, 03:57:31 pm »

Hi -- first off, THANK YOU JEROEN, this thing's great.

Probably quickest to show what I have:


Description("Localize (defrag and gather) the entire contents of !ScriptDirectory!.")
Title("Clean up !scriptdirectory! after install")
#WindowSize(invisible)
VolumeSelect
  Writable(yes) and Fixed(yes) # Don't see how to make MyDefrag derive volume from path
VolumeActions
  FileSelect not(fullpath('!ScriptDirectory!\*','*')) fileactions fileend
  FileSelect fullpath('!ScriptDirectory!\*','*.MyD') fileactions fileend
  FileSelect size(0,40000000)  FileActions SortByName(Ascending)  FileEnd
  FileSelect all fileactions defragment() fileend
VolumeEnd
whenfinished(exit)


I made this for Orbiter which loads dozens of .dll's and configs and all on startup and I'm actively working on, but it strikes me as generally useful for a quick post-install: copy it to the installed folder, doubleclick, it gets very much neater on disk about as fast as possible.

I do want the painless aspect: just the one file, drop it in, doubleclick it, done.
Logged
BloodySword
JkDefrag Hero
*****
Posts: 1114



View Profile
« Reply #1 on: October 13, 2010, 06:32:35 pm »

You can use another macro wich is defined by command line by a batch file.
You can extract parts of a path like this:

%~I         - expands %I removing any surrounding quotes (")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
%~sI        - expanded path contains short names only
%~aI        - expands %I to file attributes of file
%~tI        - expands %I to date/time of file
%~zI        - expands %I to size of file
%~$PATH:I   - searches the directories listed in the PATH
               environment variable and expands %I to the
               fully qualified name of the first one found.
               If the environment variable name is not
               defined or the file is not found by the
               search, then this modifier expands to the
               empty string
The modifiers can be combined to get compound results:

%~dpI       - expands %I to a drive letter and path only
%~nxI       - expands %I to a file name and extension only
%~fsI       - expands %I to a full path name with short names only


But only in a FOR loop...

http://stackoverflow.com/questions/636381/what-is-the-best-way-to-do-a-substring-in-a-batch-file
« Last Edit: October 13, 2010, 06:34:15 pm by BloodySword » Logged

Greetings from Germany!
amk
JkDefrag Hero
*****
Posts: 101



View Profile
« Reply #2 on: October 14, 2010, 03:49:37 pm »

But only in a FOR loop...
This feature also works with the parameters of call command
if %1 is file name
%~1 removes quotes
%~n1 expands to name without path and extension...
Logged
BloodySword
JkDefrag Hero
*****
Posts: 1114



View Profile
« Reply #3 on: October 14, 2010, 04:31:46 pm »

Oh, in this document there were only FOR loops mentioned, nice to know that it works on other variables, too.
Logged

Greetings from Germany!
jthill
Newbie
*
Posts: 2


View Profile
« Reply #4 on: October 15, 2010, 01:01:40 am »

Is there a way to include the script itself in the batch file?  Things like that are usually done with overlapping comment syntax, but so far as I can tell myd doesn't recognize block-comment openers in single-line comments.  Perhaps I'm missing it.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #5 on: October 15, 2010, 05:00:30 am »

Is there a way to include the script itself in the batch file?
Not exactly, no. Perhaps you can do what you want with macro's, see the MyDefrag "-m" commandline parameter. Or perhaps you can do it by creating a temporary MyDefrag script from your batch file, with the ">" and ">>" command redirection operators. The following command will create a file called "t1.txt" containing a line with the text "hello":
Quote
echo hello > t1.txt
And this command will append a line with "there" to that file:
Quote
echo there >> t1.txt

Quote
Things like that are usually done with overlapping comment syntax, but so far as I can tell myd doesn't recognize block-comment openers in single-line comments.
Not sure what you are trying to do, but no, MyDefrag does not see a block-comment opener in a single-line comment.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!