[jawsscripts] Re: script that adds numbers each time it is executed

  • From: Hamid <aitouznaghamid@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Wed, 16 Nov 2016 09:30:32 +0000

Hello Brian,

I am sorry to disappoint you, but no I am not familiar with the windows 
power shell at all. I am a bitfamiliar with the jaws scripting  though! 
What I understood from this file you sent me is that it presumes having 
a bunche of scanned files already in the folder but that is not the case 
actually. What I want is something easy that inserts the files name each 
time I scan it in the name's edit field with a quick keyb*oard shortcut 
instead of manually typing the name in letter by letter. I want it also 
that to save me the pain of trying to remember what was the last number 
i typed in.*

*Again sorry to disappoint you but I don't even know how to start with 
that template you sent me.*

*Thanks so much and hopefully you can provide more clarifications.*


On 16/11/2016 02:38, Brian Vogel wrote:

Hamid,
            Is there anyone (yourself included) who's familiar with Windows
Power Shell scripting?  The script that appears below gives the outline of
precisely what you want to do, and I've run it in a test folder on my
machine, but it is very "quick and dirty."  It does no parameter checking
and has no safety elements built in so if you're not careful about being in
the folder you want to run it in it has the potential to wreak havoc.  So
much for the disclaimer.

            I would create a file somewhere that contains this script text
and name it something like Rename_for_Year.ps1.  You would then copy it to
the folder where the files need to be renamed, use the context menu to open
it with notepad to tweak the year in question, save the file, then bring up
the context menu with it selected and choose "Run with PowerShell."

---------------------------------------------------------------------------------------
# Use a foreach to loop through all the files in the current directory
# This method allows us to easily track the file name so we can report
# our findings by file if you wish to echo information about what's
happening

#Set the variable for the year you wish to use in the rename
$ryear=2015

#Set first number for renaming file to 1
$i=1

#For each file found in the current directory  (and that will include this
copy of the power shell script)
foreach($curfile in Get-ChildItem ".")
{
     #Rename the current file with a number prefix ($i), followed by the
rename year ($ryear),
     #followed by its original name ($curfile) with hyphens separating each
element
     #If you wish to just have file names like 1-2015, 2-2015, etc., then
strip the final hyphen and $curfile
     # variable in the rename line below
     Rename-Item $curfile $i-$ryear-$curfile
     $i++
}
----------------------------------------------------------------------------------------

This should give you something to start with.  This can also be
accomplished via a .bat file that would run under Command Prompt rather
than Power Shell, but the syntax is a bit messier (believe it or not)

Brian



__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: