Welcome, Guest. Please login or register.

Author Topic: Looping through all directories of a partition?  (Read 3077 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Looping through all directories of a partition?
« on: October 13, 2009, 11:56:20 AM »
Hello,

I am new to scripting and I was wondering if anyone could help me achieve this. Is there a way to create a loop that loops within every directory of a partition? For example - can I make a loop that would first traverse all directories of System: and then all directories in System:C, then all sub-directories of System:C, etc.

Regards,
Sim085
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #1 on: October 13, 2009, 12:04:10 PM »
Quote from: JJ;525784
is this connected to changing icons ?


Yes - but I started a new thread because it is more related to scripting rather then changing icons (which I know how to using CLI now). I am trying to write a script that can change for everyone rather then only myself and my set-up. At the moment I am trying to backup the original icons and then I will move to the next step of copy new icons from a source directory. I will also write a restore script so that one can change from one set-up to another with relative easiness. ... although I wonder who may need this apart me :)
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #2 on: October 13, 2009, 01:35:19 PM »
Quote from: JJ;525789
Will the cli program allow you to use wildcards?
I just tried that out but does not seem to work.
Quote from: Thomas;525790
If it does not allow wildcards, you can use the List command to call the program for each file:
Thanks :) I'll see how that peace of code works.

So it seems that script files do not support for-loops and if-statements right?
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #3 on: October 13, 2009, 03:06:19 PM »
Quote from: meega;525804
Check out the startup-sequence... see if there's an If in there. ;)

For has also been implemented by third parties in a number of instances, but not in the standard Workbench/CLI/Shell iirc.


Thanks :) Yes there is an example in there! I'll see how I can use that for my script.
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #4 on: October 13, 2009, 06:15:28 PM »
Is there a way how I can insert a return line in there? I need to insert some if statements in the generated script and I cannot do that in a single line :(
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #5 on: October 13, 2009, 06:36:23 PM »
Hi, sorry to bring this up again, but does anyone know how to check if a file is a directory or not?
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #6 on: October 13, 2009, 07:06:18 PM »
Quote from: MozzerFan;525849
The "dirs" parameter for the list command will only give a list of all directories.

What I meant is if there is a way to check if for example Sys:A is a directoy or not. Something as follows:

Code: [Select]
IF Sys:A IS DIRECTORY
   ; do something
EndIF
Obviously the above code is not correct. However is there anything that can help me achieve the same?
« Last Edit: October 13, 2009, 07:08:34 PM by sim085 »
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show all replies
Re: Looping through all directories of a partition?
« Reply #7 on: October 14, 2009, 07:57:36 AM »
Ok, I managed to do what I want using Thomas previous example and MozzerFan information about 'dirs'. I have completed by first script which takes a backup of all the current icons installed on a particular partition :) Now I'll move to the next step so that I can make an installation script! These scripts are nothing special, but when ready I'll make them available for anyone who would like to use it in any way.