Jump to content

16 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 
5 hours ago, CorinaMarie said:

Double clicking the icon will execute the script and create a backup of all cities and regions in a date / time stamp style folder in the SimCity 4 folder.

A picture likely won't help here. A DOS script is essentially a bunch of code that when run, performs a set of given operations. In this case, those are described in the quote above. The idea is that these scripts allow you to automate common tasks performed on your PC. I've a number of them myself, they can be very useful.

  • Like 2

Head over to my Lot and Mod Shack to keep abreast of my latest developments.

Do you like custom textures, but don't like all the work involved creating them?, take a look at the Texture Automation options here. Change the look and feel of your transit networks, with the minimum of effort, for example customised versions of my Sidewalk NAM (SWN) and Terrain Grass NAM (TGN) mods, and much more besides.

New to the NAM? Check out my tutorials on YouTube. Latest upload: How to: RHW - MHO Roundabout Interchanges. (Nov 25).

p.s. - I'm MGB over on SC4D and a member of the NAM team.

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

i get that part, I couldn't figure out what the main idea was, because there's a save button, and the file that produces is time-stamped. I guess this saves everything at once. 

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 4/23/2016 at 0:32 AM, citycowboy said:

    I have no idea what you just said. Do you have a picture?

    I do have pics. How about a couple of them? Here's one from my test computer as I was writing the script:

    CBScrn01.jpg.ebbd8dada256349efb0e3eeab9d91cd1.jpg

    The batch file is creating those incremental sub folders. They each get a unique name based on the exact day and time they were created.

    Here's a pic from my game comp after one run:

    CBScrn02.jpg.92b6a75f4611a04f174b5e54875d27f4.jpg

    And, ofc, each sub folder contains the region.ini, config.bmp, and all the city files.

    *:)

    • Like 4

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    2016.04.23.05.32 - Expanding CoriBacks.Bat

    Ok, so I put out the above draft version of a usable back up script. It has the serious flaw of backing up all regions whether or not there have been any changes. The v0.1 beta is simply the foundation upon which further refinements can be built.

    The next thing I'll add to my personal version is Single or up to 9 specific regions via passed cmd line parameter. Much more sophisticated would be: Menu with keypress activation for custom region(s) back ups. [prog note: build menu from sub folder names]

    For those techy peeps who understand the script: The HH is parted out for another idea. Like would a concurrently running batch file interfere if it checked every 5 minutes for updates to city files? Or the simple first version would make a back up each time it sees the Hour change.

    Feel free to critique my code or provide feedback on how well this worked for you.

    • Like 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Rather neat if cumbersome for people that don't have proper backup software.  If I did not have good incremental backup software that runs automatically, I'd take a smash at converting it to a BASH script.

    @citycowboy  Hard to give you a picture because this is an operational batch script which works with the file system.  Seems to work fine, and I think it would be OK even on Windows 10.  However, in order to understand this you need to know more than somewhat about the command system that underlies the GUI (Graphical User Interface) covering up the operating system.  It amounts to a program of very high level commands to the computer depending on the operating system.  That's why I said I'd have to convert it, since it is for Windoze and I am on Linux.  Every operating system around today has the point and click GUI which actually generates little scripts of commands to the operating system to get things going.  Convenient, but indirect.   The author littered the whole thing with lots of comments to make it all easier to understand, but understanding comes with knowledge of the operating system at a deeper level.  You see, some of us who are getting to be fewer every year, started out when there was no such thing as a GUI and everything was done with command lines.

    • Like 2

    Beware: Emancipated user.  No Windoze for me.
    The teacher opens the door but the student must enter himself. - Ancient Chinese Saying

    Every minute of hate in which one indulges oneself is sixty seconds of happiness lost.
    Music expresses that which cannot be put into words and that which cannot remain silent. -- Victor Hugo
    If you always do what you've always done, you'll mostly get what you've always got.
    JohnNewSig.gif
    "We have met the enemy, and he is us" - Walt Kelly

    Come join us at the Moose Factory

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    11 hours ago, A Nonny Moose said:

    ... cumbersome for people that don't have proper backup software. ...

    I'm a wee bit confuzzled by this assertion. Is this with regard to the method the user has to create CoriBacks.Bat? Or with the inherent verbosity of dos scripting? See, once the Icon / Button is created on the desktop, the automated back up is ready to run at a moment's notice. I feel that's pretty elegant inasmuch as the steps are then: Dbl-Clk it, watch (or not), done. This beta version does require the user to police their available data space as well as to manually clean up / delete older back up copies when they are no longer needed. That last aspect can be considered non-interference concerning file(s) removal. Or cumbersome, I suppose.

     

    11 hours ago, A Nonny Moose said:

    ... in order to understand this you need to know more than somewhat about the command system that underlies the GUI (Graphical User Interface) covering up the operating system. 

    ^ Quite true. Tho some of it isn't too terribly hard to grasp the basic concepts of what's going on. I'll annotate the code here in a moment.

     

    11 hours ago, A Nonny Moose said:

    ... The author littered the whole thing with lots of comments to make it all easier to understand, ...

    Littered? Like graffiti intermingled with the code? :ooh: I consider it to be informative decoration. ;)

     

    Ok, so I'll kinda try to describe what does what in the script:

    @Echo Off <- Tells OS to not display each line of code as it is executed.
    Cls <- CLear Screen (makes it blank)

    :: CoriBacks.Bat - v0.1 beta
    :: -------------------------
    :: Written by: CorinaMarie@Simtropolis - 2016.04.22.19.35
    ::
    :: - Dos Script to make incremental backups of all SimCity 4 Cities & Regions
    ::
    :: Note: This is the down and dirty version. It does not check for available
    ::        space and the screen display could be cleaned up better.

    ^ All above lines starting with the double colons :: are REMark statements. They are just informative stuff.

    :CheckLocation <- Label which also provides a hint what's going to occur next.
      If NOT Exist Regions\*.* Echo No Regions Found. <- Ask OS if the folder Regions is where I expect it to be.
      If NOT Exist Regions\*.* Goto :NoRegions <- Bail out of script if not found.


    :GoodLocationCk1stRun <- Label
      If NOT Exist CoriBack\*.* Echo making CoriBack folder. <- Now check if the parent back up folder is there.
      If NOT Exist CoriBack\*.* md CoriBack <- If it's not there, make it. (Must be the 1st time being run.)


    :FolderInPlaceCreateSubFolderName <- Label
      Set HH=%time:~0,2% <- Grab just the two digit part of the current Hour and set a variable named HH to that value.
      Set ExactMoment=%date:~-4%%date:~4,2%%date:~7,2%_%HH%%time:~3,2%%time:~6,2%

    ^ Above line, concatenate Year and Month and Day and such to make the unique folder name for this run.

    :MakeNewIncrementalFolder <- Label
      md "CoriBack\%ExactMoment%_RegionsBackUp" <- Make Directory (that's a folder) based on unique name just created.


    :DoTheDeed <- Label
      Echo Perfomring Back Up. <- This type of Echo just means display something on the screen.
      Echo. <- With the dot . immediately after, it displays a blank line.

      xcopy Regions "CoriBack\%ExactMoment%_RegionsBackUp" /e /v

    ^ xcopy is a dos command and the x stands for eXtended. It's used here to copy all contents of the Regions folder into the newly made unique back up folder. The /e means Everything so it includes folders which are empty. (This is prolly not necessary, but I always use /e instead of /s.) And the /v means to Verify what was copied.

    :ShowResults <- Label
      Echo.
      Echo These Regions backed up to CoriBack\%ExactMoment%_RegionsBackUp
      Echo.

    ^ These 3 lines show stuff on the screen.

      Dir "CoriBack\%ExactMoment%_RegionsBackUp" /b

    ^ The Dir command is telling the OS to show a list of files. The /b means use the Bare format so the date and time and file sizes and such are not shown. For my version, I'll prolly add the /w for Wide format since I have so many test regions atm.

      Goto :Exit <- Tells the script to jump to the label :Exit


    :NoRegions <- We only get to here if the If NOT Exist Regions line above failed. Before the pause would be a good place for me to Echo more information to the screen explaining what the problem is. For this beta version I've skipped that.
      Pause <- Wait for user to press a major key.
      Goto :Exit <- Jump to the :Exit label. In this case it could just fall thru, but by habit I include it so if I add more subroutines I don't bork myself by forgetting it.


    :Exit <- Label
      Echo.
      Echo Ready to Exit CoriBacks.Bat
      Echo.

    ^ Show stuff on screen.


      Pause <- Wait.

      Exit <- Close the little dos box and exit from the dos command session.

     

    I especially like batch files because the erudite user can see everything which is going to happen when the script is executed.

     

    Punch in a Like if this was helpful. :blush:

     

    • Like 6

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    15 hours ago, A Nonny Moose said:

    Rather neat if cumbersome for people that don't have proper backup software.

    The problem with such scripts is simple. If you understand the script, you probably won't need to download one. After all, more advanced users are less likely to use defaults, preferring their own setups. As such, scripts are limited to working with very specific folders/files. Although you could edit them, many users simply wouldn't know how.

    Perhaps that's the issue, those who don't really understand what the script is doing, may be put off, despite being the obvious target audience. Considering BAT files are notorious for setting of alarm bells with Anti-Virus and other security tools. As such, those who don't understand them might be easily put off downloading or running such scripts.

    For my money, the only thing I'd change is perhaps the location of the backups. Since to be truly useful a backup should be on external storage somewhere. This is where the scripting system can fall down, since without a lot of complex code, file/folder locations must usually be set in stone. Not to mention expecting the average user to manually define the path for such backups is probably doomed to failure.

    I tend not to use backup software myself, having never really found a solution I liked. SyncToy however is a really useful tool for managing the process. Part of the advanced PowerToys for Windows, some of which are quite handy.

    15 hours ago, A Nonny Moose said:

    The author littered the whole thing with lots of comments to make it all easier to understand

    I don't think Nonny's use of littered here is a negative. Given his abilities with coding, I'm sure he can appreciate when someone takes the time to comment their code. I must say, starting off with systems with 7kb of memory, I tend to work on the frugal side with comments. There simply wasn't the memory to be verbose in those times.

    • Like 1

    Head over to my Lot and Mod Shack to keep abreast of my latest developments.

    Do you like custom textures, but don't like all the work involved creating them?, take a look at the Texture Automation options here. Change the look and feel of your transit networks, with the minimum of effort, for example customised versions of my Sidewalk NAM (SWN) and Terrain Grass NAM (TGN) mods, and much more besides.

    New to the NAM? Check out my tutorials on YouTube. Latest upload: How to: RHW - MHO Roundabout Interchanges. (Nov 25).

    p.s. - I'm MGB over on SC4D and a member of the NAM team.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    4 hours ago, rsc204 said:

    The problem with such scripts is simple. If you understand the script, you probably won't need to download one.

    I have no doubt many members here could, and prolly have, written their own. As I expand this script's capabilities I believe there might be some of those who could but haven't written their own deciding to use mine. Perhaps with minor tweaks.

     

    4 hours ago, rsc204 said:

    ... those who don't really understand what the script is doing, may be put off, despite being the obvious target audience.

    Caution is a very good survival trait. I do imagine there are peeps of all levels of knowledge who might have some interest in this. Some will be willing to learn what a very small handful of commands can do and will see the benefit for same. And, the peeps who have no idea what the arcane instructions do, can simply rely on other peeps to tell them if this thing is dangerous or useful.

    Many peeps already know how to manually make back ups of their sub folders. In later versions of CoriBacks.Bat, I'll have it do user selectable specific regions (rather than all as it is now). This being a completely open source project let's everyone see what it'll do and discuss that. I feel it's much more convenient to give the OS a list of instructions it will perform faithfully than to rely on my memory while I do c & p stuff manually.

     

    4 hours ago, rsc204 said:

    For my money, the only thing I'd change is perhaps the location of the backups.

    Absolutely. If there turns out to be some interest in later versions of this, that's a must-have feature. And it's not really as difficult as I feel you portray it for the batch file to have that flexibility. ;)

     

    Edit: About the littering: I was playfully picking a nit with Granpa's word choice. The emoticons are intended to show my mirthful acceptance of the whole statement along with my alternate definition.


      Edited by CorinaMarie  

    Add Littering Insight

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Well, I could have said 'included' or 'scattered' with respect to comments.  Just to give you an idea of my coding these days, here is my SC4 startup script for DirectX rendering:

    #!/bin/bash
    date
    echo "Starting SimCity 4 Deluxe - DirectX rendering"
    env WINEPREFIX="/home/john/.wine" \
    wine "C:/Program Files (x86)/Maxis/SimCity 4 Deluxe/Apps/SimCity 4.exe" \
     -intro:off -CustomResolution:enabled -r1920x1080x32 -d:directx \
     -CPUCount:1 -f &>~/sc4.log
    wine --version &>>~/sc4.log
    date


    As you can see, it is very operating system (Linux) and shell interpreter (BASH) dependent.  One thing about Linux is that there are several shell interpreters available, but BASH is the current preferred one.  (BASH ::= Bourne Again SHell)

    I like to know when something was run and when it finished, so we have a couple of commands to display the date and time

    Funny, the echo command seems to be the same in all shells.

    The next four lines are one big line.  The backslash at the end of a line in this shell means "ignore the new line".  This is the wine system call for the program.

    Now, the wine system is very verbose.  It puts a lot of stuff on the default console (sysout), so I redirect it to a file called /home/<me>/sc4.log so that if there is a problem I can send it in to winehq, and the last thing that goes on that file is the version number of the current wine environment.

    Since this really isn't intended for anyone else's use, I tend to not comment.

    There is a lot of assumed knowledge here, like shell redirect to file (&><file>), and shell append to file (&>><file>, and the use of the tilde (~) for the base directory of the current user.  Using the BASH is like learning a new programming language.  The manual is 300+ pages long.  Linux shells tend to be very powerful.

    • Like 1

    Beware: Emancipated user.  No Windoze for me.
    The teacher opens the door but the student must enter himself. - Ancient Chinese Saying

    Every minute of hate in which one indulges oneself is sixty seconds of happiness lost.
    Music expresses that which cannot be put into words and that which cannot remain silent. -- Victor Hugo
    If you always do what you've always done, you'll mostly get what you've always got.
    JohnNewSig.gif
    "We have met the enemy, and he is us" - Walt Kelly

    Come join us at the Moose Factory

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    3 hours ago, A Nonny Moose said:

    The backslash at the end of a line in this shell means "ignore the new line".  This is the wine system call for the program.

    I believe you prolly mean the backslash says: ignore the <LF>,<CR> pair (ascii 10 & 13) produced by pressing the <enter key> and to treat the next line as if it were a continuation of the current one. ;)

     

    3 hours ago, A Nonny Moose said:

    Since this really isn't intended for anyone else's use, I tend to not comment.

    Understandable since you already know when you look at it again, you'll know what does what if'n you wish to change something. No need to tell yourself the obvious. My batch file above can be reduced to three important lines and the Exit command if I've created the backup folder previously and I know I've placed my code in the correct location.

    I did specifically  write mine with the intention that other peeps could learn it, tweak it, or just plain use it. And that it would have some security checks where it can decide if'n it's in the right place. I'll keep an eye on this thread and see if there's any interest for me to add the additional options mentioned. (It might be interest in sc4 and underlying utilities like this has waned too much for my efforts to be of any use to anyone.)

    Vote with Hearts on my posts here if you want to see more from me on this topic. :blush:

     

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Almost.  Lines in a Linux file end with only a <LF>.  The CTRL+m is considered redundant, so Linux saves a lot of storage by doing away with  it.  In Linux parlance this really is called a "newline character". 

    I used to write Windoze scripts in the day, but for the life of me I can't recall what the meta-character is for "ignore this new line sequence".  Because Linux makes heavy use of pipes and commands within commands, there are many long, continued lines in a script.  Being able to break them up arbitrarily makes maintenance a lot easier.

    And if you think the confusion in file string separators is something else again, the Multics file system used greater than sign (>) so you could get strings like this:

    >home>jcw>documents>"simcity 4">plugins.

    It has been about 50 years since I used a Multics system, but it was one of the things I always hated because '>' is a first shift character.


    Beware: Emancipated user.  No Windoze for me.
    The teacher opens the door but the student must enter himself. - Ancient Chinese Saying

    Every minute of hate in which one indulges oneself is sixty seconds of happiness lost.
    Music expresses that which cannot be put into words and that which cannot remain silent. -- Victor Hugo
    If you always do what you've always done, you'll mostly get what you've always got.
    JohnNewSig.gif
    "We have met the enemy, and he is us" - Walt Kelly

    Come join us at the Moose Factory

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, A Nonny Moose said:

    I used to write Windoze scripts in the day, but for the life of me I can't recall what the meta-character is for "ignore this new line sequence".

    I learned its name as Line Continuation Character. In the script it's the caret ^. In my younger years (ok, still to this day) I imagine a caret was a carrot like leading the text onward to the next physical line without stopping to see the cliff it was about to leap down from.


    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Thanks.  It is amazing how trivial details like that get lost over time.  I haven't run Windoze since 2007 which I guess could count as a decade as time flies.  The complex syntax of most scripting languages that use wild cards becomes embedded in the brain after a while. 

    You really have to know the difference between quote marks (" ", ' ', ` `) with the BASH because something different happens with each.  This particular shell is loaded with built-in commands and has the capability of being extended ad infinitum.  I use it because it is the default, but I don't use much of it any more.  This old noggin doesn't remember all the niceties these days without a manual to look them up.

    • Like 1

    Beware: Emancipated user.  No Windoze for me.
    The teacher opens the door but the student must enter himself. - Ancient Chinese Saying

    Every minute of hate in which one indulges oneself is sixty seconds of happiness lost.
    Music expresses that which cannot be put into words and that which cannot remain silent. -- Victor Hugo
    If you always do what you've always done, you'll mostly get what you've always got.
    JohnNewSig.gif
    "We have met the enemy, and he is us" - Walt Kelly

    Come join us at the Moose Factory

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections