Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

External Program to rename file

I have an article and a folder with the same name in my citydesk 2.0 file.  CD doesn't like this and renames the article by appending a "-2" to the name of the artcile when I publish it.

At this point, I'm not in a position to rename the folder or the article since people have linked to both the article and to files within the folder. 

I was wondering if anyone new the command line syntax to rename a file.  I want to run it before the site is FTPed to the server to rename my file with the appended "-2".  I am using Win XP and am its been too long since I used DOS environment variables.

Thanks for the help. 

P2
Wednesday, November 19, 2003

P2 :re magic names

Did you know that by using the built-in "magic name" CD gives each and every file [or article] you have within folders -- you can then rename any file [or srticle] and it will not have an impact on the links --- the key however is to use the *magic names* when linking. The only time that magic names do not work is in "includes"

Using “magic names” have many other benefits as well. How does one get at the magic name? highlight any article [or file] within CD and right-click, then select copy magic name. Once you have that in the clipboard you then can paste wherever you need too.

David Mozer
Wednesday, November 19, 2003

Thanks David.  I have used magic names and I'm not sure if this solves my problem. The difficulty isn't the link to the file.  It's that a colleague has directed people involved in a study to a file that was moved into a subfolder (& subdomain) and given the index.html name.  I thought I could work around this by having two copies of the file indifferent folders, but CD2 doesn't want to share the folder and article name.  I guess I cld create a redirect outside of CD and FTP it to the server.  This might be better than renaming the html file after CD has recreated the site but before it gets FTPed to the directoty (my initial plan this morning)

P2
Wednesday, November 19, 2003

move file1.html file2.html

Michael H. Pryor (fogcreek)
Wednesday, November 19, 2003

You can create a .bat file and call that .bat file after processing.  That way if you have more than one command to issue they can all be in the batch file.

Jeff Kolker
Wednesday, November 19, 2003

You could also use the excellent CopyBoy ( http://www.larkware.com/Products/LarkwareCopyBoy20.html ). It gives you the power to edit publishing names of all articles once and for all. So there you can remove the -2 extension on the file. It works fine, I've had the same situation myself.

Henrik Jernevad
Thursday, November 20, 2003

If your pages are hosted on a linux server you could set a redirect instruction in the ".htaccess" file.

It is simply a text file called .htaccess and its content needs to look like:

Redirect /olddirectory/index.html http://yoursite.com/actualdirectory/index-2.html

(all on one line). If a .htaccess file is already in place it's best to check the contents of that file else you might undo other settings for other folders.

Dan
Thursday, November 20, 2003

Actually, it's probably a lot easier to create a new index.html file and put in the head tags:

<Meta content=2;URL=http://yoursite.com/actualdirectory/index-2.html http-equiv=refresh>

Users who hit this page will be redireted to index-2.html

Dan
Thursday, November 20, 2003

I thought that if you added some text to the name of an article in brackets (), that when published everything but that in brackets would make up the file name.

Does CD still append a "-2" to an article, even if it has some text in brackets to distinguish it from a folder name?

i.e. if the folder’s called "index" and you want a file alongside it called "index.html" from an article, could you not name the article "index (article)" to get what you want?

Or am I having a bad day? (I've never used this feature, so I apologise if I got it horribly wrong).

Ian Jones
Thursday, November 20, 2003

"Does CD still append a "-2" to an article, even if it has some text in brackets to distinguish it from a folder name?"

Yes, because if you publish with no extention then you will have two items - the folder and the file - with the exact same name.

That's a big no-no on some OS's.

www.MarkTAW.com
Thursday, November 20, 2003

I don't like the meta-refresh idea so much because the page everyone links to will have nothing on it, yet Google will index it.

Sounds like the CopyBoy solution is the best one.

www.MarkTAW.com
Thursday, November 20, 2003

Wow.  Lots of different strategies. Thanks for the advice. 

Ian:  Your point around the parentheses was an eye opener.  I don't recall reading this tip and didn't see it in the documentation when I searched it this week.  However, it must work because I have a file called index(site) that is published as index.html.  I either learned this tip early in the days of purchasing CD and forgot it or fluked into it. 

I went to the copyboy site earlier this week and it certainly has features that would be useful.  Until this week, my web development was mostly on the hobby side. Now that I am using the site to achieve certain work objectives, I may purchase the add-on. 

P2
Thursday, November 20, 2003

I might be wrong here, and I don't have the posibility to test it right now, but I don't think adding something within parantheses will help you. The name conflict (between the folder and the file) exists after CityDesk has stripped away the parts of the article name that should not be published (like text within parantheses) and therefore -2 is added. I might be wrong though.

Yet another way to go: You can achieve the same result as you can with CopyBoy if you open the CityDesk site in Microsoft Access. The publishing names of articles are stored within a table so it's pretty straightforward to change it (just remove -2) from the article's publishing name. You shouldn't do this if you're not used to working in Access though, you have the posibility to seriously damage your site.

Henrik Jernevad
Friday, November 21, 2003

Ah well, shame that parantheses can't help.

I would have thought that CityDesk could analyse all the names of folders, files and articles after parantheses have been removed and extensions applied. That way you could have a folder and article with the same name, as long as parantheses were used in th article name and that it's template had an extension. If the article didn't have an extension when published then sure enough there would be a clash of names and the article could aquire a "-2" or whatever.

But it obviously isn't so, ho hum.

Fog Creek peeps, maybe this could be looked into as a tweak for the future? I see this as bug.

Ian Jones
Friday, November 21, 2003

Regarding the naming issue: Let's say we have two files names "article (about something)" and "article (about something else)" in the same folder. When they are published, both files get the publishing name "article", hence the need for adding a number after.

One might argue though that CityDesk could handle the situatione differently when a file and a folder have a naming "conflict" since most OS:es don't care if a folder and file have the same name. On the other hand, some weird OS *might* care, so therefore I would say that the current behaviour is preferable.

Henrik Jernevad
Friday, November 21, 2003

CityDesk should do the comparison *after* the file extension from the appropriate template has been added.  Then it could see that a folder named "index" and a file named "index.html" have distinct names, and would leave them alone.

Kevin
Wednesday, July 07, 2004

*  Recent Topics

*  Fog Creek Home