AusGamers Forums
Show: per page
1
Windows/samba usability help
thermite
Brisbane, Queensland
9824 posts
OK I maintain a whole bunch of websites which are on a development server, and sometimes I want to open all the same files from the different websites all at once.

e.g.
/www/whorepresents/config/database.cfg
/www/penisisland/config/database.cfg
/www/therapistfinder/config/database.cfg
/www/expertsexchange/config/database.cfg
...
etc...
but there are dozens of sites

I want to open all the database.cfg files in my shitty editor, all at once, so I can do some 'replace all' magic - 2 seconds - and be done with it.


I can putty into the server, type a LOT, and edit stuff in VIM.. don't like doing that!
The server is mounted as a network drive on my windows 7, so I can click about and find the file I want in each site and drag it into an editor.... too hard.
I can use windows search to find all the files with the same name... too. god. damn. slow.


So who can think of a way I can do this easily? Ideally it would be like the windows search option where I get all the icons up.. and just drag them over to my editor and BAM, except a shitload faster. I don't know what takes windows search so long.. like an hour... maybe more.



10:41am 29/06/12 Permalink
adBot
ads
Internet
--
ads keep websites free
10:41am 29/06/12 Permalink
Jim
UK
12956 posts
find /www/*/config -name database.cfg |xargs sed -i 's/replace_this/with_this/g'
10:57am 29/06/12 Permalink
tspec
Melbourne, Victoria
3584 posts
I know windows search is slow but could you not do that as a once off, highlight all the files you want to edit, right click (and with Notepad++ or another tabbed editor installed), click Edit with Notepad++, it'll open all the selected files in their own tabs. Edit and save the files but not close the tabs. If you close the tabs, there's always the recent saved history as well to reopen things. I'm sure there's more efficient ways to accomplish this but might work in the meantime.
11:00am 29/06/12 Permalink
Opec
Brisbane, Queensland
7630 posts
find /www/*/config -name database.cfg |xargs sed -i 's/replace_this/with_this/g'


Heh I was about to post something similar but because I'm such a *nix gumby now it took me ages to write that shell script hahaha

Perhaps add something like this to ensure you're only opening "files" in case there's folders with the same name:


find /www/*/config -type f -name database.cfg | xargs sed -i 's/replace_this/with_this/g'
11:04am 29/06/12 Permalink
thermite
Brisbane, Queensland
9825 posts
I have used this before, sometimes it was an easy change and this was fine, a lot of times the changes were too complicated to come up with that replace pattern reliably, and quite often I need to click through to several files where the change wasn't applied because of inconsistencies.
11:05am 29/06/12 Permalink
Jim
UK
12957 posts
if regex is too hard, maybe google how to sort out your windows search cos I also do exactly what you're describing with windows search and it takes ~1 second
11:09am 29/06/12 Permalink
Opec
Brisbane, Queensland
7631 posts
Well I supposed if you want you can do something like:
- create the find script on the server, drop the list into a file
- replace all the actual samba's path with your windows' samba path like \\foobar\shared\
- write a little batch script that does loops opens the above file, on your windows PC then just opens the file something like:

"C:\Program Files (x86)\Notepad++\notepad++.exe" "%1%"

That'll then loads _all_ the files into your Notepad++ in multiple tabs.
11:12am 29/06/12 Permalink
thermite
Brisbane, Queensland
9826 posts
this batch idea might be the go
11:19am 29/06/12 Permalink
Dazhel
Gold Coast, Queensland
5016 posts
Windows 7? PowerShell:

dir -recurse www\*\config\database.cfg | foreach { notepad $_ }

Basically like Jim's solution, but opens notepad for each file instead of replacement with sed.

or
dir -recurse www\*\config\database.cfg | select -expand FullName | "C:\Program Files\notepad++\notepad++.exe"
11:40am 29/06/12 Permalink
thermite
Brisbane, Queensland
9827 posts
Got a problem with the batch file, I came up with this:



set /p server="Enter server e.g. DVB: "
set /p sitelist="Enter site list e.g. active_site_list_gs3: "
set /p filename="Enter file path e.g. /conf/database.cfg: "

FOR /F %%A IN (\\%server%\websites\%sitelist%) DO "C:\Program Files (x86)\notepad++\notepad++.exe" \\%server%\websites\%%A%filename%


It opens notepad++ with just the first file, then waits till I exit notepad++ before opening the 2nd, etc....

12:45pm 29/06/12 Permalink
Jim
UK
12958 posts
find out if the way to open multiple files in notepad++ is to pass them as multiple arguments, then build your argument list with the loop instead of running notepade++ in it
01:13pm 29/06/12 Permalink
thermite
Brisbane, Queensland
9828 posts
solved


FOR /F %%A IN (\\%server%\websites\%sitelist%) DO START "" "C:\Program Files (x86)\notepad++\notepad++.exe" \\%server%\websites\%%A%filename%


empty set of quotes there are important
01:35pm 29/06/12 Permalink
jesu
Brisbane, Queensland
702 posts
Wtf, notepad++ has a recursive find and replace function inbuilt... ctrl+f click the tab, specify a top path and voila
09:05pm 29/06/12 Permalink
thermite
Brisbane, Queensland
9830 posts
I guess i'll check it out, but ftr I find notepad++ find&replace functionality pretty pitiful, I had to get a plugin to replace it, which uses a separate thing to the one-liner shit you get at ctrl+f.
Plus find&replace isn't everything, these sites are a clusterfuck from a dozen different developers, so you wind up hitting maybe 2/3 of them via search and replace, then maybe another 5 sites with another find&replace, then the rest with another. It's good to have them all there to be able to switch through and see them all bang bang bang get it done.

last edited by thermite at 21:19:29 29/Jun/12
09:16pm 29/06/12 Permalink
jesu
Brisbane, Queensland
703 posts
I guess i'll check it out, but ftr I find notepad++ find&replace functionality pretty pitiful, I had to get a plugin to replace it, which uses a separate thing to the one-liner shit you get at ctrl+f.
Plus find&replace isn't everything, these sites are a clusterfuck from a dozen different developers, so you wind up hitting maybe 2/3 of them via search and replace, then maybe another 5 sites with another find&replace, then the rest with another. It's good to have them all there to be able to switch through and see them all bang bang bang get it done.last edited by thermite at 21:19:29 29/Jun/12

Oh OK I understand where you're coming from now. Be glad you can leave all files open in notepad++
09:26pm 29/06/12 Permalink
Whoop
Brisbane, Queensland
20161 posts
I guess i'll check it out, but ftr I find notepad++ find&replace functionality pretty pitiful, I had to get a plugin to replace it, which uses a separate thing to the one-liner shit you get at ctrl+f.
Plus find&replace isn't everything, these sites are a clusterfuck from a dozen different developers, so you wind up hitting maybe 2/3 of them via search and replace, then maybe another 5 sites with another find&replace, then the rest with another. It's good to have them all there to be able to switch through and see them all bang bang bang get it done.last edited by thermite at 21:19:29 29/Jun/12

I don't think it's fair to blame notepad++ if the sites were all written differently. That's like blaming mspaint because it can't open nikon raw files.
09:55am 30/06/12 Permalink
adBot
ads
Internet
--
ads keep websites free
09:55am 30/06/12 Permalink
AusGamers Forums
Show: per page
1
This thread is archived and cannot be replied to.
 

Advertise with Us | Download Media Kit | Privacy Policy | Contact Us
© Copyright 2001-2013 AusGamers™ Pty Ltd. ACN 093 772 242.
A Mammoth Media web development, hosted by Mammoth VPS.