Solved

Syntax Issue

Posted on 2012-03-26
14
260 Views
Last Modified: 2012-03-28
Hi All,

Have a problem with a client. Need to upload documents to Sharepoint / Office 365 but getting an error and its down to a filenaming issue.

My client for the last 6 year has been adding a "." a the end of file he saves

So the net result is a file that looks like below when file ext is visable

Accounts..xls
bills..xls

About two thousand of these in various folders and subfolders in my docs,

is there a program that can be run to remove the "."

all help appreciated

Regards

Noel
0
Comment
Question by:PC_Mechanic
  • 4
  • 3
  • 3
  • +2
14 Comments
 
LVL 51

Expert Comment

by:Bill Prew
ID: 37768584
I'm on a mobile device right now so can't test, but have you tried

Ren *..xls *.xls

Try it on a test folder with a couple of the sample files in it to be renamed and see how it goes.

~bp
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37768938
Hmm, I don't think that will Bill, at least it didn't for me?

Try this as a batch file "fixfiles.cmd" or similar.... on a test / copy of the dirs of course.  It will run down all the subdirs showing you what it will do.  if it looks good then remove the word REM

Steve

@echo off
setlocal enabledelayedexpansion
cd /d c:\thedirectory

for /r %%a in (*..*) do (
  set name=%%~na
  set name=!name:~0,-1!
  REM rename "%%a" "!name!%%~xa"
  echo Renaming %%a to "!name!%%~xa"
)
0
 
LVL 11

Assisted Solution

by:paultomasi
paultomasi earned 200 total points
ID: 37768968
Here you go:

NOTE: Change line 4 to point to your starting folder.
@echo off
setlocal enabledelayedexpansion

set folder=c:\

for /r  "%folder%" %%a in (*..*) do (
  set fn=%%~na
  set fn=!fn:~0,-1!
  ren "%%~fa" "!fn!%%~xa"
)

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37768983
Paul, that's the same as mine!
0
 
LVL 11

Assisted Solution

by:paultomasi
paultomasi earned 200 total points
ID: 37769004
Wow! Steve, our codes are almost identical! Shows it's the RIGHT way to do this.

Here's an optional way:
@echo off
setlocal enabledelayedexpansion

set folder=c:\

for /r  "%folder%" %%a in (*) do (
  set fn=%%~na
  ren "%%~fa" "!fn:..=.!%%~xa"
)

Open in new window

NOTE: This one has the advantage of renaming any filename containing '..'
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37769013
True Paul, I decided against doing the replace .. with . in case there were other .. or more dots within the name but frankly doesn't really matter a lot either way if a dot is lost I guess.

Steve
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37769018
Hahaha... Seems like we are cross-posting!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 51

Accepted Solution

by:
Bill Prew earned 300 total points
ID: 37769652
Rereading the original post, it sounds like a script wasn't a requirement, just a "program".  To that end, here are several rename utilities that are free that I have looked at for things like this that you could check out to see if you like their approach better.

http://www.bulkrenameutility.co.uk/Main_Intro.php
http://file-folder-ren.sourceforge.net/index.php?page=Main
http://www.den4b.com/?x=products&product=renamer
http://rename.lupasfreeware.org/
http://www.advancedrenamer.com/

~bp
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 37769666
Guys, it was fun reading your comments.  After a long absence (which I'm not completely back), I feel like Dartanian having a beer with his fellow Musketeers.

Please forgive my intrusion but for what it's worth, I would vote for Steve and Paul's first (almost at the same time) posts.

Adding to the FWIW, I have users naming file names with strange chars combinations, including ".."

So by replacing ".." by ".", may be a challange if the users had shortcuts on there desktops or they would be referenced somehow (backup software, Sharepoint...) with "..".

For example "Accounting..Finance..Employees..Office Supplies.xls".

Well I dont know Sharepoint, so your are the best juge on this.

Just adding my possible extra cheese, to the pizza!!

Cheers,
Rene
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 37769678
@Bill

You have a point. However, the poster put MS DOS as the primary Topic.

I will look at your renaming utilities, I will surely find an interesting tool.

We still did not get any feedback from the poster.

Cheers,
Rene
0
 

Author Comment

by:PC_Mechanic
ID: 37779122
Wow,

Didn't think id get so much feedback from the question. Will test and report back, I was off for a few days.

Thanks,

Noel
0
 

Author Closing Comment

by:PC_Mechanic
ID: 37779351
The Advance renamer program worked a treat

So ill award the most points to BP as the "program" made it so easy

also 100 points each to Paul and Steve for technical genius

Regards,

Noel
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 37779371
Thanks, glad that helped.

~bp
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37780257
Thank you
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This comprehensive conference-networking guide will help you prep, practice and pack for success, reach out with purpose and confidence, capitalize on connections, and turn all those new leads into long-term connections.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now